Computer Science, asked by ameehuncyjoey, 1 year ago

Wap a program in c++ pattern 1 121 12321

Answers

Answered by sahilbhilave
2
#include<iostream.h> 
#include<conio.h> 
void main() 

     int i, j, n = 5; 
     clrscr(); 

     for(i=1; i<=n; i++) 
      { 
         for(j=1; j<=i; j++) 
          { 
              cout <<" "<<j ; 
          } 

         j -= 2; 
         for(; j>=1; j--) 
          { 
              cout <<" "<<j ; 
          } 

         cout << "\n" ; 
      } 
     getch(); 

sahilbhilave: this answer was in for loop
sahilbhilave: if you want a short method then use while(++a || ++b) and print a and b
Similar questions