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.
Nested loop Structures Semi-Pyramid
Page 1 of 11 Replies - 686 Views - Last Post: 25 June 2012 - 01:39 AM
Replies To: Nested loop Structures Semi-Pyramid
#2
Re: Nested loop Structures Semi-Pyramid
Posted 25 June 2012 - 01:39 AM
** Duplicate topic **
Page 1 of 1

New Topic/Question
This topic is locked



MultiQuote


|