1 Replies - 686 Views - Last Post: 25 June 2012 - 01:39 AM Rate Topic: -----

#1 leam   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 25-June 12

Nested loop Structures Semi-Pyramid

Posted 25 June 2012 - 01:33 AM

hello C++ users, im in need of help regarding with the nested loop.

here's the question..

Write a program that will display the pattern below depending on the value of n.

Sample output:

Enter a value of n: 4

output:

*
**
***
****
***
**
*

i need ur response
Ive tried answering it and here’s my work:



#include<iostream>
using namespace std;
main()

{
int a;
cout<<"Enter a value of n: ";
cin>>a;
cout<<endl;

for(int x=1; x<=1; x++)
{
for (int y=1;y<=1;y++)
cout<<"*";
cout<<endl;
}

for(int x=1; x<=1; x++)
{
for (int y=1;y<=2;y++)
cout<<"*";
cout<<endl;
}
for(int x=1; x<=1; x++)
{
for (int y=1;y<=3;y++)
cout<<"*";
cout<<endl;
}
for(int x=1; x<=1; x++)
{
for (int y=1;y<=4;y++)
cout<<"*";
cout<<endl;
}
for(int x=1; x<=1; x++)
{
for (int y=1;y<=3;y++)
cout<<"*";
cout<<endl;
}
for(int x=1; x<=1; x++)
{
for (int y=1;y<=2;y++)
cout<<"*";
cout<<endl;
}
for(int x=1; x<=1; x++)
{
for (int y=1;y<=1;y++)
cout<<"*";
cout<<endl;
}



system("pause");
return 0;
}


Sad to say it’s still wrong.

Is This A Good Question/Topic? 0
  • +

Replies To: Nested loop Structures Semi-Pyramid

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Nested loop Structures Semi-Pyramid

Posted 25 June 2012 - 01:39 AM

** Duplicate topic **
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1