KAR98S

NxN Star.c

Feb 10th, 2021 (edited)
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. //code to print NxN cross using '*'
  2. #include<stdio.h>
  3.  
  4. int main(){
  5.     int n, i, j;
  6.     scanf("%d", &n);
  7.     for (i = 0; i < n; i++) {
  8.         for (j = 0; j < n; j++) {
  9.             if (i == j || i + j == n-1) {
  10.                 printf("*");
  11.             }
  12.             else {
  13.                 printf(" ");
  14.             }
  15.         }
  16.         printf("\n");
  17.     }
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment