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


Please Help Members By Posting Answers For Below Questions

What is a null pointer in c?

595


Explain c preprocessor?

683


Explain how can a program be made to print the name of a source file where an error occurs?

687


Differentiate Source Codes from Object Codes

822


Explain what header files do I need in order to define the standard library functions I use?

649






Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

815


What is the use of linkage in c language?

617


What is .obj file in c?

648


What is a const pointer?

638


Is fortran still used today?

604


Can we add pointers together?

620


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

602


What functions are used in dynamic memory allocation in c?

597


How to find a missed value, if you want to store 100 values in a 99 sized array?

816


What are global variables and explain how do you declare them?

578