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
What is calloc malloc realloc in c?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
Explain what are compound statements?
Where are c variables stored in memory?
What is use of #include in c?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
Describe wild pointers in c?
How do you initialize pointer variables?
What is a pointer in c plus plus?
What is the use of clrscr?
Why structure is used in c?
Write a code on reverse string and its complexity.
Can we access the array using a pointer in c language?
Explain what are the different file extensions involved when programming in c?
How to define structures? ·