Wednesday, 25 May 2016


Write a program in C++ to display the following output using nested for loop:


   Solution: 

       #include<iostream.h> 
       #include<conio.h> 
       void main()
       {
              int i , j; 
              clrscr();
              for(i = 0; i<=5; i++)
              {
                    for(j=0; j<=5; j++)
                    if(i == 0 || i ==5 || j == 0 || j == 5)
                        cout<<"*"; 
                    else 
                         cout<<" "; 
                     cout<<"\n";
              }
              getch();
       }
                                                                             

3 comments: