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
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
Write a code to generate divisors of an integer?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
Can stdout be forced to print somewhere other than the screen?
What is table lookup in c?
Write a program for finding factorial of a number.
What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?
Explain the array representation of a binary tree in C.
Is c still used?
Why we use void main in c?
Can an array be an Ivalue?
What is a header file?
How to declare a variable?
what is recursion in C
Explain what is dynamic data structure?