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

Answer Posted / vignesh1988i

sorry i have done a small mistake ..... this is correct

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,k;
printf("enter the no. of lines :");
scanf("%d",&n);
for(i=1;i<=(n*2-1);i++)
{
if(!(i^1)|| !(i^(n*2-1)))
{
for(j=1;j<=(n*2-1);j++)
printf("*");
}
else
{
if(i<=n)
{
for(j=1;j<=n-i;j++)
printf("*");
for(k=1;k<(2*(i-1));k++)
printf(" ");
for(j=n-i;j>=0;j--)
printf("*");
if(i==n)
{
k--;
m=k;
}
}
else
{
for(j=1;j<=(i-n+1);j++)
printf("*");
for(j=k;k<=k-n-1;k++)
printf(" ");
k-=2;
for(j=i-n+1;j>0;j--)
printf("*");
}
}
getch();
}

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are qualifiers in c?

574


Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80

2561


Is c procedural or functional?

590


List the variables are used for writing doubly linked list program.

1626


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2008






What are near, far and huge pointers?

650


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

922


What is the size of structure in c?

705


What are global variables and explain how do you declare them?

582


what is the height of tree if leaf node is at level 3. please explain

1604


I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.

1500


How does sizeof know array size?

634


can we change the default calling convention in c if yes than how.........?

2037


c program for searching a student details among 10 student details

1658


Explain what is the benefit of using an enum rather than a #define constant?

728