Write a program to give following output.....
*********
**** ****
*** ***
** **
* *
** **
*** ***
**** ****
*********
Answers were Sorted based on User's Feedback
Answer / monty
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
for(a=1;a<10;a++)
{
for(b=1;b<10;b++)
{
if((a==2 && b==5) ||
(a==3 && (b==4 || b==5 || b==6) )
||
(a==4 && (b>=3 && b<=7) )
||
(a==5 && (b>=2 && b<=8) )
||
(a==6 && (b>=3 && b<=7) )
||
(a==7 && (b==4 || b==5 || b==6) )
||
(a==8 && b==5))
printf("-");
else
printf("*");
}
printf("\n");
}
getch();
}
Is This Answer Correct ? | 5 Yes | 1 No |
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 |
#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);k++)
printf(" ");
for(j=n-i;j>=0;j--)
printf("*");
}
else
{
for(j=1;j<=(i-n+1);j++)
printf("*");
for(j=k-3;k<=(2*n-1);k++)
printf(" ");
for(j=i-n+1;j>0;j--)
printf("*");
}
}
getch();
}
i think this may work
thank u
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / 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 |
What is structure of c program?
what does ‘#include’ mean?
enum DAY { sunday, monday, tuesday }; enum EDAYS { friday, saturday, sunday }; void main() { int i =0; if( i == sunday) { printf("%d",i); } } what would be the output?
get any number as input except 1 and the output will be 1.without using operators,expressions,array,structure.don't print 1 in printf statement
Explain demand paging.
triangle number finding program...
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
What is s or c?
What is the significance of scope resolution operator?
0 Answers Agilent, ZS Associates,
What are the 5 types of inheritance in c ++?
In the following code segment what will be the result of the function, value of x , value of y { unsigned int x=-1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); } a) same, MAXINT, -1 b) not same, MAXINT, -MAXINT c) same , MAXUNIT, -1 d) same, MAXUNIT, MAXUNIT e) not same, MAXINT, MAXUNIT
What is pass by reference in c?