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)
printf("*\n");
else{
for(j=0;j<i;j++)
printf("*");
printf("\n");
}
}
return 0;
}
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
What are the difference between a free-standing and a hosted environment?
Describe the order of precedence with regards to operators in C.
What is extern variable in c with example?
Explain what is a static function?
In which header file is the null macro defined?
What does emoji p mean?
Write a program to use switch statement.
p*=(++q)++*--p when p=q=1 while(q<=6)
What is character set?
What is the basic structure of c?
What functions are used for dynamic memory allocation in c language?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
Difference between strcpy() and memcpy() function?
how to find binary of number?