Write a program in c using only loops to print *
* *
* *
*******
Answer Posted / evr
This is the generic code for printing above such pattern. You can print the above pattern for different number of rows by entering different value during run time
#include<stdio.h>
int main()
{
int n, i, j;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=0;i<n;i++)
if(i!= n-1)
{
for(j=1;j<=2*n;j++)
{
if(j==n-i || j==n+i)
printf("*");
else
printf(" ");
}
printf("\n");
}
else
for(i=0;i<2*n-1;i++)
printf("*");
return 0;
}
Thank you......
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is return type in c?
Why do we use int main instead of void main in c?
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
When should a type cast be used?
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
how can use subset in c program and give more example
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
What is a macro?
Under what circumstances does a name clash occur?
Why main is used in c?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
What are valid signatures for the Main function?
Explain modulus operator. What are the restrictions of a modulus operator?
What is line in c preprocessor?
Create a simple code fragment that will swap the values of two variables num1 and num2.