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


Please Help Members By Posting Answers For Below Questions

What is return type in c?

642


Why do we use int main instead of void main in c?

626


please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code

1711


When should a type cast be used?

577


#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); }

786






how can use subset in c program and give more example

1505


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

660


What is a macro?

657


Under what circumstances does a name clash occur?

694


Why main is used in c?

592


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

679


What are valid signatures for the Main function?

703


Explain modulus operator. What are the restrictions of a modulus operator?

602


What is line in c preprocessor?

618


Create a simple code fragment that will swap the values of two variables num1 and num2.

816