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 far pointer in c?

1013


How can you avoid including a header more than once?

754


Describe the header file and its usage in c programming?

835


What is the use of parallelize in spark?

765


Explain the use of 'auto' keyword

884


Can a pointer be volatile in c?

732


In C language, a variable name cannot contain?

1014


What is the difference between union and anonymous union?

1050


What is meant by inheritance?

851


Differentiate call by value and call by reference?

757


What does the message "automatic aggregate intialization is an ansi feature" mean?

929


Where are local variables stored in c?

773


What is the function of volatile in c language?

879


What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.

2032


What are preprocessor directives in c?

847