Thursday, March 7, 2013

Write a program in C to print following pattern or triangle

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
*
**
***
****
*****
******
*******
                                                               For Download Click below

No comments:

Post a Comment