-->





Translate

Showing posts with label box shape. Show all posts
Showing posts with label box shape. Show all posts

C++ Program to print box shape using for loop

4 comments
Program Specifications:
  • Program uses for loops only to print box shape
  • Symbol used is asterisk (*)
  • Program prints fixed size box
  • To change the size change the values of for loops

    C++ Code:
    1. #include<iostream>
    2. using namespace std;
    3. int main()
    4. {
    5.      for(int a=1;a<=10;a++)
    6.         {
    7.             cout<<"*";
    8.         }
    9.             cout<<endl;
    10. for(int b=1;b<=5;b++)
    11.     {
    12.     for(int c=1;c<=1;c++)
    13.         {
    14.                 cout<<"*";
    15.         }
    16.         for(int d=1;d<=8;d++)
    17.               {
    18.                 cout<<" ";
    19.               }
    20.                 cout<<"*"<<endl;
    21.        }
    22. for(int e=1;e<=10;e++)
    23.  {
    24.  cout<<"*";
    25.  }
    26.  return 0;
    27. }

    Image View Of Code:(click image for large view)
    box shape using for loop c++ Programming
    C++ box shape using for loop c++ Programming
    box shape using for loop c++ Programming
    Sample Output:(Click on Image To View in Big Size)

     
     More Programs:
    
    C++ Shapes Programs
    
    C++ Simple Programs
    
    As in programming there are always more than one 
    ways to code try more than one ways to learn fast.
    
Read More...