Tuesday, 22 November 2016

Write a program to generate the following pyramid of digits using nested loop



        
        #include <iostream.h>
        #include <conio.h>
        int main ()

        {
             int  mid; 

             for (int i= 1; i <= 10; i++)
             {
                   cout<< " " ; 
                  mid = (2 * i) - 1;

                  for (int j =1; j <=(10 - i); j++)
                     cout<< " " ;  

                  for (j = i; j<= mid; j++)
                     cout<<( j %10 ); 

                  for (j = (mid - 1); j >=i; j--)
                     cout<<( j %10 );

                  cout<< endl;
             }
              return 0;

        }


Output: 


No comments:

Post a Comment

If you have any doubt please let me know

Methods in JAVA Language

 In general, a way may be thanks to perform some task. Similarly, the tactic in Java may be a collection of instructions that performs a sel...