Answer to Question #319663 in C for Sami

Question #319663

write a C program which will print following pattern on monitor

*

**

***

****

*****

******


1
Expert's answer
2022-03-30T14:10:42-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS