Write a Program to print this triangle:
*
**
*
****
*
******
*
********
*
**********
use two nested loops.
Answer Posted / rfk
#include<stdio.h>
int main()
{
int n,i,j;
printf("enter the lines :");
scanf("%d",&n);
for(i=1;i<=n/2;i++)
{
printf("*\n");
for(j=1;j<=2*i;j++)
printf("*");
printf("\n");
}
if(n%2!=0)
printf("\n*");
}
compiled with GCC
| Is This Answer Correct ? | 13 Yes | 7 No |
Post New Answer View All Answers
What is signed and unsigned?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
What is define directive?
Function calling procedures? and their differences? Why should one go for Call by Reference?
What are near, far and huge pointers?
Can stdout be forced to print somewhere other than the screen?
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
Explain the use of 'auto' keyword in c programming?
What is a structure and why it is used?
Is main is a keyword in c?
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
Explain the properties of union.
What is wrong with this code?
Explain logical errors? Compare with syntax errors.
How is pointer initialized in c?