1. write a C program to print a triangle.
*
**
***
****
*****
solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a;
printf("enter the any number to print a triangle\n\t");
scanf("%d",&a);
for(i=0;i<a;i++)
{
for(j=0;j<=i;j++)
{
printf("*");
}
printf("\n");
}
getch();
}
No comments:
Post a Comment