write a program in c to print ****
* *
* *
****
Answer Posted / rajkumar
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=0;i<=3;i++)
{
printf("*");
}
for(i=4;i<5;i++)
{
printf(" ");
}
for(i=5;i<6;i++)
{
printf("*");
}
for(i=6;i<7;i++)
{
printf(" ");
}
for(i=7;i<8;i++)
{
printf("*");
}
for(i=8;i<9;i++)
{
printf(" ");
}
for(i=9;i<10;i++)
{
printf("*");
}
for(i=10;i<11;i++)
{
printf(" ");
}
for(i=11;i<12;i++)
{
printf("*");
}
for(i=12;i<13;i++)
{
printf(" ");
}
for(i=12;i<=15;i++)
{
printf("*");
}
getch();
}
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
Explain union. What are its advantages?
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
What is the use of static variable in c?
How can I do graphics in c?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
Is fortran faster than c?
What is the use of bit field?
What is f'n in math?
Can a pointer be volatile in c?
Explain how can I pad a string to a known length?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
What is the best way to store flag values in a program?
Do you know what are the properties of union in c?
How will you write a code for accessing the length of an array without assigning it to another variable?
why return type of main is not necessary in linux