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

about c language

1699


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

727


while initialization of array why we use a[][2] why not a[2][]...?

1960


What is scope rule in c?

705


What is nested structure in c?

699






what do you mean by inline function in C?

705


What does dm mean sexually?

931


What is the use of ?

713


What does 3 periods mean in texting?

691


What is volatile c?

639


Explain what is wrong in this statement?

736


How do I get a null pointer in my programs?

743


1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

2027


What is the purpose of the statement: strcat (S2, S1)?

722


Explain what is output redirection?

759