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 |
int a=20; int b=30; int c=40; printf("%d%d%d"); what will be the output?
Taking an example,differentiate b/w loader and linker ?
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
What is I ++ in c programming?
What is a lookup table in c?
How can I determine whether a machines byte order is big-endian or little-endian?
Which is an example of a structural homology?
When do we get logical errors?
main() { int i=5; printf("%d%d%d%d",i++,i--,i); }
what is the function of pragma directive in c?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
CopyBits(x,p,n,y) copy n LSBs from y to x starting LSB at 'p'th position.