Write a Program to print this triangle:
*
**
*
****
*
******
*
********
*
**********
use two nested loops.

Answer Posted / rfk

#include<stdio.h>
int main()
{
int n,i,j;
printf("enter the lines :");
scanf("%d",&n);
for(i=1;i<=n/2;i++)
{
printf("*\n");
for(j=1;j<=2*i;j++)
printf("*");
printf("\n");
}
if(n%2!=0)
printf("\n*");

}

compiled with GCC

Is This Answer Correct ?    13 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is different between auto and local static? why should we use local static?

644


What is the difference between #include

and #include “header file”?

552


What is the use of extern in c?

647


Why is extern used in c?

612


Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

1865






How does selection sort work in c?

621


There seem to be a few missing operators ..

619


Do you know the use of 'auto' keyword?

662


Stimulate calculator using Switch-case-default statement for two numbers

2448


Is javascript based on c?

595


Write a progarm to find the length of string using switch case?

1612


What is the full form of getch?

585


What is difference between structure and union in c?

546


What is else if ladder?

607


Is it acceptable to declare/define a variable in a c header?

685