Write a Program to print this triangle:
*
**
*
****
*
******
*
********
*
**********
use two nested loops.
Answer Posted / adhiraj keshri
#include<stdio.h>
main()
{
int n;
printf("enter the lines");
scanf("%d",&n);
for(int i=1;i<=n/2;i++)
{
printf("*\n");
for(int j=1;j<=2*i;j++)
printf("*");
printf("\n");
}
if(n%2!=0)
printf("\n*");
}
| Is This Answer Correct ? | 4 Yes | 5 No |
Post New Answer View All Answers
Why is c still so popular?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
How can I read a binary data file properly?
Is malloc memset faster than calloc?
What are the primitive data types in c?
Is it better to use a macro or a function?
What is the purpose of sprintf?
What is strcpy() function?
What is the use of clrscr?
What is switch in c?
What is optimization in c?
What are keywords in c with examples?
What is restrict keyword in c?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
What are the 5 types of inheritance in c ++?