I did not bother to name this...

From Morose Ibis, 2 Months ago, written in Plain Text, viewed 31 times.
URL http://codebin.org/view/be8ea681 Embed
Download Paste or View Raw
  1. // asks the user for an int and keeps asking him until it is between 1 and 8, then builds a pyramid with it
  2. #include <stdio.h>
  3. #include <cs50.h>
  4.  
  5. int main (void)
  6. {
  7.     int height;
  8.     bool greater = false;
  9.     bool smaller = false;        
  10.     // asks the user for an int and keeps asking him until it is between 1 and 8,
  11.     do
  12.     {
  13.         height = get_int ("gib number between 1-8 \n");
  14.         if (height > 8)
  15.         {
  16.             greater = true;
  17.         }
  18.         else if (height < 1)
  19.         {
  20.             smaller = true;
  21.         }
  22.         else
  23.         {
  24.             greater = false;
  25.             smaller = false;
  26.                
  27.         }
  28.     }
  29.     while (greater || smaller);    
  30.     //builds the pyramid
  31.     for (int row = 0; row < height; row++)
  32.     {
  33.       int j;
  34.       for (j = height - row - 1; j > 0; j--)
  35.       {
  36.           printf(" ");  
  37.       }
  38.         int l;
  39.         for (l = 2; l > 0; l--)
  40.         {
  41.             int k;
  42.             for (k = row + 1;  k > 0; k--)
  43.                 {
  44.                     printf("#");  
  45.                 }
  46.                     printf("  ");                            
  47.         }
  48.         printf("\n");
  49.      
  50.      
  51.        

Reply to "I did not bother to name this..."

Here you can reply to the paste above