Write a program in C to print following pattern or triangle
*
**
***
****
*****
******
*******
Solution:
/*Write a program in C to print following pattern or triangle*/
#include<stdio.h>
#include<conio.h>
main()
{
int n;
clrscr();
printf("Enter number of Rows\t");
scanf("%d",&n);
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
printf("*");}
printf("\n");}
getch();
}
Output: Enter number of Rows 7
*
**
***
****
*****
******
*******
*
**
***
****
*****
******
*******
Solution:
/*Write a program in C to print following pattern or triangle*/
#include<stdio.h>
#include<conio.h>
main()
{
int n;
clrscr();
printf("Enter number of Rows\t");
scanf("%d",&n);
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
printf("*");}
printf("\n");}
getch();
}
Output: Enter number of Rows 7
*
**
***
****
*****
******
*******
No comments:
Post a Comment