Advertisement
Divyansh_Chourey

pyramid_of_num

Mar 10th, 2024 (edited)
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | Source Code | 0 0
  1. #include<stdio.h>
  2. int main(){
  3.     int i, j, k, num;
  4.     printf("Enter the number: ");
  5.     scanf("%d", &num);
  6.     k=num/2;
  7.     for(i=1; i<=num; i++){
  8.         printf("\n");
  9.        
  10.         if(i%2!=0){
  11.             for (int a = i/2; a < k; a++) {
  12.                 printf(" ");
  13.             }
  14.             for(j=1; j<=i; j++){
  15.                 printf("%d", j);
  16.             }
  17.         }
  18.        
  19.     }
  20.     return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement