how to print this pyramid *
*
*
* * * * * * *
*
*
*
Answers were Sorted based on User's Feedback
Answer / j.n.abhishek
void main()
{
int n,i,j;
clrscr();
printf("ENTER THE LIMIT:");
scanf("%d",&n);
for(i=0;i<=(2*n);i++)
{
if(i!=n)
{
for(j=0;j<(2*n);j++)
{
printf(" ");
}
printf("+\n");
}
else
{
for(j=0;j<=(2*n);j++)
{
printf("+ ");
}
printf("\n");
}
}
getch();
}
| Is This Answer Correct ? | 3 Yes | 1 No |
more generic answer considering for any value n (odd or even)
void printPlus(int n)
{
int i, j;
for(i=0; i<=n; i++)
{
if(i == n/2)
{
for(j=0; j<n; j++)
{
printf("* ");
}
printf("\n");
// to ignore last step of drawing for odd cnt
if(n%2 != 0)
{
i++;
}
}
else
{
for(j=0; j<n/2; j++)
{
printf(" ");
}
if(n%2 == 0)
{
// even
printf("\b*\n");
}
else
{
// odd
printf("*\n");
}
}
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
i=10,j=20 j=i,j?(i,j)?i:j:j print i,j
What’s a signal? Explain what do I use signals for?
Why we not create function inside function.
Differentiate between full, complete & perfect binary trees.
What is the advantage of a random access file?
Iam a B.Tech graduate and completed my engineering in 2009, from 2005 to 2009 and after that i had done nothing.Now i want to do job and get into BPO field . Friends give me suggestions as what to say in interview... if they ask me that what would you had done ... these many years without doing job ??????? pls urgent
Does c have an equivalent to pascals with statement?
What is context in c?
convert 0.9375 to binary
What is the use of getch ()?
Why c is called a mid level programming language?
What is an auto keyword in c?