how to print this pyramid *
*
*
* * * * * * *
*
*
*
Answer Posted / senthil
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 |
Post New Answer View All Answers
Who invented bcpl language?
How do you view the path?
plz let me know how to become a telecom protocol tester. thank you.
Sir i need notes for structure,functions,pointers in c language can you help me please
what is different between auto and local static? why should we use local static?
hi, which software companys will take,if d candidate's % is jst 55%?
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?
What is a method in c?
is it possible to create your own header files?
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
Why dont c comments nest?
Write a program to check whether a number is prime or not using c?
Tell me about low level programming languages.
How can I get random integers in a certain range?
What library is sizeof in c?