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.
Answers were Sorted based on User's Feedback
Answer / dhanashree n.gavade
int i,j,m;
m=2;
for(i=0;i<5,i++)
{
putch('*');
putch('\n');
for(j=i;j<=j+m;j++)
putch('*');
m=j;
putch('\n');
}
Is This Answer Correct ? | 15 Yes | 6 No |
Answer / 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 |
Answer / gana
{
int a,b=2,i;
char *s="\0";
for(i=0;i<5;i++)
{
for(a=0;a<5-i;a++)
putch(' ');
for(a=0;a<b;a++)
putch('*');
b+=2;
puts(s);
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / reshma m.
int i,j,m;
m=2;
for(i=0;i<5;i++)
{putch('*');
putch('\n');
for(j=0;j<m;j++)
{putch('*');
m+=2;
}
putch('\n');
}
Is This Answer Correct ? | 4 Yes | 5 No |
Answer / 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 |
Difference between malloc() and calloc() function?
struct ptr { int a; char b; int *p; }abc; what is d sizeof structure without using "sizeof" operator??
void main() { int *ptr; ptr = (int *) 0x400 ; printf("ptr=%d",ptr); } output?
What is #include called?
What is the difference between char a[] = "string"; and char *p = "string"; ?
14 Answers Adobe, Honeywell, TCS,
What is the usage of the pointer in c?
Write a C++ program without using any loop (if, for, while etc) to print numbers from 1 to 100 and 100 to 1;
18 Answers Accenture, Cisco, Egentec, HCL, Ideaz, Infosys, M-Systems, MYR, TCS,
What is your favorite subject?
1 Answers Ericsson, Invendis, Tech Mahindra,
What is c++ used for today?
Will Macros support multiple arguments ?
Concat two string with most overlapped substring has to removeĀ "abcd"+ "cdef" = "abcdef
in linking some of os executables are linking name some of them