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 is the scope of static variable in c?
what is the function of pragma directive in c?
Explain what is the advantage of a random access file?
What is a macro in c preprocessor?
What does the error 'Null Pointer Assignment' mean and what causes this error?
When a c file is executed there are many files that are automatically opened what are they files?
List some basic data types in c?
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
What are the advantages of external class?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
Which one would you prefer - a macro or a function?
Why void is used in c?
Process by which one bit pattern in to another by bit wise operation is?
Whats s or c mean?
What is pointer & why it is used?