C program to print reverse pyramid star pattern
#include<stdio.h> int main() { int i, space, rows, star; printf ( "Enter the number of rows\n" ); scanf ( "%d" ,&rows); for (i = rows;i >= 1; i--) { /* Printing spaces */ for (space = 0; space <= rows-i; space++) { printf ( " " ); } /* Printing stars */ star = 0; while (star != (2*i - 1)) { printf ( "*" ); star++; } printf ( "\n" ); } return 0; }
|
No comments:
Post a Comment