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 many data structures are there in c?
Explain how can I remove the trailing spaces from a string?
Explain that why C is procedural?
What does c mean?
Why is c called a mid-level programming language?
Is calloc better than malloc?
Explain what is the difference between the expression '++a' and 'a++'?
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
Explain the difference between strcpy() and memcpy() function?
What is the equivalent code of the following statement in WHILE LOOP format?
Which header file is used for clrscr?
Explain the difference between null pointer and void pointer.
What are the two types of structure?
What is function what are the types of function?
What is bin sh c?