fork download
  1. /* Write a program to take n as input and print 1 to n in the following order.
  2.  * 1
  3.  * 1 2
  4.  * 1 2 3
  5.  * 1 2 3 4
  6.  * 1 2 3 4 n
  7.  */
  8.  
  9. #include <stdio.h>
  10.  
  11. int main(void) {
  12. // your code goes here
  13. int num = 4;
  14.  
  15. for (int k =3; num >=(num-k);k--)
  16.  
  17. {
  18. for (int i=0 ; num>i; i++)
  19. {
  20. printf("%d",num-i);
  21. }
  22. printf("\n");
  23.  
  24.  
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 620KB
stdin
Standard input is empty
stdout
4321
4321
4321
4321