Advertisement
TheWhiteFang

Tutorial 2 section A

Nov 2nd, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int value = 0;
  8.     cout << "Enter a number between 1 & 20: ";
  9.  
  10.     //scanf(%d , &value); //c
  11.     cin >> value; //c++
  12.  
  13.     int i = 0; int j = 0;
  14.     for(i = 0; i < value; i++)
  15.     {
  16.         for(j = 0; j < value; j++)
  17.         {
  18.             if( i==0 || i == (value-1) || j==0 || j== (value-1)) // ||- logical or  //if j is first or last value, print * //if checks for true false in statement
  19.             {
  20.                 cout <<"* ";
  21.             }
  22.  
  23.             else //this will happen if it is either not 1st value or last value
  24.             {
  25.                 cout << "  ";
  26.             }
  27.  
  28.            
  29.  
  30.         }
  31.  
  32.         cout << endl;
  33.     }
  34.  
  35.     cout << endl; //cout << "\n"
  36.  
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement