- Back to Home »
- PATTERN PROGRAMS »
- pattern programs
Posted by : ANIMESH SHAW
Tuesday, 1 May 2012
Write a C program to
print the following pattern:
*
*
*
*
* *
* *
* *
Program:
/* This is a simple
mirror-image of a right angle triangle */
#include <stdio.h>
int main() {
char prnt = '*';
int i, j, nos = 4, s;
for (i = 1; i <= 5; i++) {
for (s = nos; s >=
1; s--) { // Spacing factor
printf(" ");
}
for (j = 1; j <= i; j++) {
printf("%2c", prnt);
}
printf("\n");
--nos;
// Controls the spacing factor
}
return 0;
}

Post a Comment