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


Please Help Members By Posting Answers For Below Questions

Write a program to print factorial of given number without using recursion?

563


Differentiate between the = symbol and == symbol?

703


What are the features of c language?

617


Why static is used in c?

614


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

2854






What are unions in c?

572


What is a string?

661


Define the scope of static variables.

596


What are volatile variables in c?

513


The difference between printf and fprintf is ?

714


Can a pointer be volatile in c?

529


How can you be sure that a program follows the ANSI C standard?

1121


Explain bitwise shift operators?

626


What is the use of printf() and scanf() functions?

623


What is the difference between array and linked list in c?

593