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 far pointer in c?
How can you avoid including a header more than once?
Describe the header file and its usage in c programming?
What is the use of parallelize in spark?
Explain the use of 'auto' keyword
Can a pointer be volatile in c?
In C language, a variable name cannot contain?
What is the difference between union and anonymous union?
What is meant by inheritance?
Differentiate call by value and call by reference?
What does the message "automatic aggregate intialization is an ansi feature" mean?
Where are local variables stored in c?
What is the function of volatile in c language?
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
What are preprocessor directives in c?