WRITE A PROGRAM TO PRINT THE FOLLOWING OUTPUTS USING FOR
LOOPS.
A) * B) *****
*** * *
***** * *
*****
Answers were Sorted based on User's Feedback
Answer / vignesh1988i
for a)
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("enter the number of terms :");
scanf("%d",&n);
for(int i=0;i<=n+i;i++)
{
for(int j=0;j<n-1 ;j++)
printf(" ");
for(j=0;j<=(2*i);j++)
printf("* ");
printf("\n");
n--;
}
getch();
}
for b):
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf("enter the no. of terms :");
scanf("%d",&n);
for(int i=1;i<=5;i++)
{
printf("\n");
if(i==1 || i==n)
{
for(j=0;j<n;j++)
printf("* ");
}
else
{
printf("* ");
for(j=0;j<n-2;j++)
printf(" ");
printf("* ");
}
}
getch();
}
Is This Answer Correct ? | 14 Yes | 6 No |
Answer / vutukuru
#include<stdio.h>
main()
{
int i,j,n=5;
clrscr();
for(i=0;i<n-4;i++)
{
printf("*");
}
printf("\n");
for(i=0;i<n-2;i++)
{
printf("*");
}
printf("\n");
for(i=0;i<n;i++)
{
printf("*");
}
getch();
}
Is This Answer Correct ? | 18 Yes | 12 No |
What is a lookup table in c?
Write a c program using for loop in switch case?
code for bubble sort?
C program to find frequency of each character in a text file?
How can I return multiple values from a function?
int main() { int days; printf("enter days you are late"); scanf("%d",days); if (days<=5) printf("5o paisa fine"); if (days<=10&&days>=6) printf("1rs fine"); if(days>10) printf("10 rs fine"); if(days=30) printf("membership cancelled"); return 0; } tell me whats wrong in this program? is it right?
What will be the outcome of the following conditional statement if the value of variable s is 10?
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
program for following output using for loop? 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
how to set Nth bit of variable by using MACRO
What are enumerated types?
if the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one of the item