Showing posts with label write a program in C. Show all posts
Showing posts with label write a program in C. Show all posts

Thursday, March 7, 2013

Decision Control Structure (if-else-if)


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