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
How can variables be characterized?
What is the general form of function in c?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
How to write a code for implementing my own printf() and
scanf().... Please hep me in this... I need a guidance...
Can you give an coding for c... Please also explain about
the header files used other than #include
Explain about block scope in c?
Explain the use of #pragma exit?
Can you pass an entire structure to functions?
Write a program to use switch statement.
What is the use of define in c?
can anyone suggest some site name..where i can get some good data structure puzzles???
What is the difference between local variable and global variable in c?
how many key words availabel in c a) 28 b) 31 c) 32
Write a program to check palindrome number in c programming?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
How do you generate random numbers in C?