Write a program to print this triangle:
*
**
*
****
*
******
*
********
*
**********
Don't use printf statements;use two nested loops instead.
you will have to use braces around the body of the outer
loop if it contains multiple statements.
Answer Posted / rakesh
#include<stdio.h>
int main()
{
int i,j;
for(i=1;i<=10;i++){
if(i%2!=0)
{
putchar('*');
putchar('\n');
}
else{
for(j=0;j<i;j++)
putchar('*');
putchar('\n');
}
}
return 0;
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
Can a pointer point to null?
When do we get logical errors?
What is printf () in c?
What is difference between function overloading and operator overloading?
Can main () be called recursively?
Multiply an Integer Number by 2 Without Using Multiplication Operator
What is structure and union in c?
What is a MAC Address?
What is the difference between abs() and fabs() functions?
Which node is more powerful and can handle local information processing or graphics processing?
What is console in c language?
Why does not c have an exponentiation operator?
Write a program to find the biggest number of three numbers in c?
What is the use of gets and puts?
What is array in C