How to create the following design using nested loops & & & & & & & & & & & & & & & & & & & & | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to create the following design using nested loops & & & & & & & & & & & & & & & & & & & &

Please help me!!!!!!

25th Sep 2016, 10:34 AM
Soutik
Soutik - avatar
6 Answers
+ 7
#include <iostream> using namespace std; int main() { int n, i, j; cout << "Insert number: "; cin >> n; for(i=0;i<n;i++) { if(i==0){ for(j=0;j<n-1;j++) cout<<" "; cout<<"&\n"; } else if(i==n-1){ for(j=0;j<n*2-1;j++) cout<<"&"; } else{ for(j=0;j<n-i-1;j++) cout<<" "; cout<<"&"; for(j=0;j<i*2-1;j++) cout<<" "; cout<<"&\n"; } } return 0; }
25th Sep 2016, 2:06 PM
marcram
+ 4
#include <iostream> using namespace std; int main() { int n, i, j; cout << "Insert number: "; cin >> n; for(j=0;j<n-1;j++) cout<<" "; cout<<"&\n"; for(i=0;i<n-2;i++) { for(j=0;j<n-i-2;j++) cout<<" "; cout<<"&"; for(j=0;j<1+(2*i);j++) cout<<" "; cout<<"&\n"; } for(j=0;j<n*2-1;j++) cout<<"&"; return 0; }
25th Sep 2016, 1:41 PM
marcram
- 2
eldxtxxrlllzeez
24th Nov 2016, 3:36 AM
Pavan Chourasiya
Pavan Chourasiya - avatar
- 2
eldxtxxrlllzeez lol l
24th Nov 2016, 3:36 AM
Pavan Chourasiya
Pavan Chourasiya - avatar
- 2
eldxtxxrlllzeez lol l
24th Nov 2016, 3:36 AM
Pavan Chourasiya
Pavan Chourasiya - avatar
- 2
eldxtxxrlllzeez lol l
24th Nov 2016, 3:36 AM
Pavan Chourasiya
Pavan Chourasiya - avatar