write a C program which will print following pattern on monitor
*
**
***
****
*****
******
#include <stdio.h>
void triangle(int n) {
int x, y;
for (y=0; y<n; y++) {
for (x=0; x<=y; x++) {
printf("*");
}
printf("\n");
}
}
int main() {
int n = 6;
triangle(n);
return 0;
}
Comments
Leave a comment