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
Write a program to print factorial of given number without using recursion?
Differentiate between the = symbol and == symbol?
What are the features of c language?
Why static is used in c?
please help me..... please codes and flowchart plz turbo c lang po yan.....please asap response... 3. Make an astrology program. The user types in his or her birthday (month, day, and year as integer), and the program responds with the user’s zodiac sign, horoscope, and other information related to it. If the user’s birth year falls into a leap year, your program should display an appropriate message for it. NOTES: Conditional Statements: it should be with graphics
What are unions in c?
What is a string?
Define the scope of static variables.
What are volatile variables in c?
The difference between printf and fprintf is ?
Can a pointer be volatile in c?
How can you be sure that a program follows the ANSI C standard?
Explain bitwise shift operators?
What is the use of printf() and scanf() functions?
What is the difference between array and linked list in c?