fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n;
  5. printf("Enter the number: \n");
  6. scanf("%d",&n);
  7.  
  8.  
  9.  
  10. for(int i=1;i<=n;i++){
  11.  
  12. for(int sp=1;sp<=n-i;sp++){
  13. printf(" ");
  14. }
  15. int a=1;
  16. for(int j=1;j<=i;j++){
  17. printf(" %d ",a);
  18. a++;
  19. }
  20.  
  21. for(int k=1;k<=i-1;k++){
  22. printf(" * ");
  23. }
  24.  
  25. printf("\n");
  26. }
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 5284KB
stdin
7
stdout
Enter the number: 
                   1 
                1  2  * 
             1  2  3  *  * 
          1  2  3  4  *  *  * 
       1  2  3  4  5  *  *  *  * 
    1  2  3  4  5  6  *  *  *  *  * 
 1  2  3  4  5  6  7  *  *  *  *  *  *