fork download
  1. //Q50. Write a program to print the following pattern:
  2. //*****
  3. //****
  4. //***
  5. //**
  6. //*
  7.  
  8. #include <stdio.h>
  9.  
  10. int main() {
  11. int n = 5;
  12.  
  13. for (int i = n; i >= 1; i--) {
  14.  
  15. for (int s = 0; s < n - i; s++)
  16. putchar(' ');
  17.  
  18. for (int j = 0; j < i; j++)
  19. putchar('*');
  20. putchar('\n');
  21. }
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
*****
 ****
  ***
   **
    *