Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Why do we use c for the speed of light?

1103


Difference between Function to pointer and pointer to function

1019


What is the difference between the local variable and global variable in c?

927


Explain what is wrong in this statement?

1068


the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above

989


Why is C language being considered a middle level language?

1043


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

6188


What is malloc calloc and realloc in c?

1216


Differentiate call by value and call by reference?

916


Why doesn't C support function overloading?

2610


What are high level languages like C and FORTRAN also known as?

1106


Explain the binary height balanced tree?

1124


Why c is called a middle level language?

1052


What is masking?

1102


What is sizeof int in c?

1003