Abdulg

Print a cross

Jan 8th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int Columns = 0;
  6.     printf("How many columns would you like? ");
  7.     scanf("%d", &Columns);
  8.  
  9.     int Row = 0;
  10.     int Counter = 0;
  11.  
  12.     while (Row >= 0)
  13.     {
  14.         int i;
  15.         for (i = 0; i < Row; i++) printf(" ");
  16.         printf("x");
  17.  
  18.         if (Row != Columns / 2)
  19.         {
  20.             for (i = 0; i <= Columns - 2 * (Row + 1) - 1; i++) printf(" ");
  21.             printf("x");
  22.         }
  23.  
  24.         Counter++;
  25.         if (Counter > Columns / 2) Row--;
  26.         else Row++;
  27.         printf("\n");
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment