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 a null pointer in c?
Explain c preprocessor?
Explain how can a program be made to print the name of a source file where an error occurs?
Differentiate Source Codes from Object Codes
Explain what header files do I need in order to define the standard library functions I use?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
What is the use of linkage in c language?
What is .obj file in c?
What is a const pointer?
Is fortran still used today?
Can we add pointers together?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
What functions are used in dynamic memory allocation in c?
How to find a missed value, if you want to store 100 values in a 99 sized array?
What are global variables and explain how do you declare them?