Write a program in c using only loops to print *
* *
* *
*******
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / veera
#include<stdio.h>
#include<math.h>
main()
{
clrscr();
printf("*");
printf("\n");
printf("* *");
printf("\n");
printf("* *");
printf("\n");
printf("*******");
getch();
}
Is This Answer Correct ? | 2 Yes | 4 No |
What are volatile variables?
what is used instead of pointers in java than c?
what is the difference between while and do while?
What are advantages and disadvantages of recursive calling ?
12 Answers College School Exams Tests, Evolving Systems, HP, Jyoti Ltd, Sage, Wipro,
What is the Difference between Class and Struct?
What is the difference between union and anonymous union?
Can a binary search tree be used as an index? If yes, how? Explain
What is the meaning of ?
Explain what will the preprocessor do for a program?
What was noalias and what ever happened to it?
What is the benefit of using an enum rather than a #define constant?
who developed c and why he developed c?