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...

Write a program to give following output.....
*********
**** ****
*** ***
** **
* *
** **
*** ***
**** ****
*********

Answer Posted / prakash

int main()
{
int i, j, star, space, n, middle;

printf("Enter the max. number of stars in a line:");
scanf("%d", &n);
printf("Output:\n");

star = n/2;
space = 1;
middle = n/2 + 1;

for (j = 1; j <= n; j++)
printf("*");
printf("\n");

for (i = 2; i <= (n - 1); i++)
{
for (j = 1; j <= n; j++)
{
if ((j >= (star + 1)) &&
(j <= (star + space)))
{
printf(" ");
}
else
{
printf("*");
}
}

// calculate a and b
if (i < middle)
{
star -= 1;
space += 2;
}
else
{
star += 1;
space -= 2;
}

printf("\n");
}

for (j = 1; j <=n; j++)
printf("*");
printf("\n");

return 0;
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

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

941


What are the 5 types of organizational structures?

1037


Why does the call char scanf work?

1171


#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }

1083


What are the types of unary operators?

1150


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

1067


What is the difference between malloc() and calloc() function in c language?

1044


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

1375


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

2543


Does c have circular shift operators?

1202


What is assignment operator?

1023


Explain what are run-time errors?

1056


What are the different types of endless loops?

1039


What is keyword in c?

974


Why is sprintf unsafe?

1012