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 you find the day of the week given the date?
How to implement a packet in C
What is a global variable in c?
How will you divide two numbers in a MACRO?
What oops means?
How can you increase the size of a dynamically allocated array?
Is it possible to have a function as a parameter in another function?
Why can’t we compare structures?
What is a structure and why it is used?
What are data types in c language?
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters
Can variables be declared anywhere in c?
What is use of bit field?
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?