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 |
What is a pointer?
what is the main use of c where it can use the c
WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..
Without Computer networks, Computers will be half the use. Comment.
how can u print a message without using any library function in c
simple program for virtual function?
int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation.
Evaluate the following: int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; } for fn(7); 1) 10 2) 11 3) 1
Write the program for displaying the ten most frequent words in a file such that your program should be efficient in all complexity measures.
what is level of tree if leaf node is at level 4.please explain.
main() { int i; printf("%d",scanf"%d",&i))//if the input is 12 24 34 then wat will be the output }
How will you find a duplicate number in a array without negating the nos ?