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
What is a list in c?
Explain what are the different file extensions involved when programming in c?
Is null valid for pointers to functions?
What is malloc() function?
What is meant by type specifiers?
What does the message "automatic aggregate intialization is an ansi feature" mean?
Explain how do you search data in a data file using random access method?
explain what are actual arguments?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
What does the characters “r” and “w” mean when writing programs that will make use of files?
How many types of sorting are there in c?
What are the functions to open and close the file in c language?
What is pre-emptive data structure and explain it with example?
Explain the difference between the local variable and global variable in c?
What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?