If a, b, c, d, e, f, g corresponds to Sunday, Monday,Tuesday...., respectively.
ID: 3589823 • Letter: I
Question
If a, b, c, d, e, f, g corresponds to Sunday, Monday,Tuesday...., respectively. Write a code that prints out the lowest number and its respective day of the week. Example starting with “a” as a Sunday, a = 1; b =2, c = 3; d = 6; e = 5; f = 1; and g = 2; Print out “The lowest number is 1 on Sunday and Friday. This is a C program and arrays are not allowed. If a, b, c, d, e, f, g corresponds to Sunday, Monday,Tuesday...., respectively. Write a code that prints out the lowest number and its respective day of the week. Example starting with “a” as a Sunday, a = 1; b =2, c = 3; d = 6; e = 5; f = 1; and g = 2; Print out “The lowest number is 1 on Sunday and Friday. This is a C program and arrays are not allowed. a = 1; b =2, c = 3; d = 6; e = 5; f = 1; and g = 2; Print out “The lowest number is 1 on Sunday and Friday. This is a C program and arrays are not allowed. e = 5; f = 1; and g = 2; Print out “The lowest number is 1 on Sunday and Friday. This is a C program and arrays are not allowed.Explanation / Answer
#include<stdio.h>
void main()
{
int a,b,c,d,e,f,g,min;
printf(" enter value for a");
scanf("%d",&a);
min=a;
printf(" enter value for b");
scanf("%d",&b);
if(b<min){min=b;}
printf(" enter value for c");
scanf("%d",&c);
if(c<min){min=c;}
printf(" enter value for d");
scanf("%d",&d);
if(d<min){min=d;}
printf(" enter value for e");
scanf("%d",&e);
if(e<min){min=e;}
printf(" enter value for f");
scanf("%d",&f);
if(f<min){min=f;}
printf(" enter value for g");
scanf("%d",&g);
if(g<min){min=g;}
int count=0;
printf(" The lowest number is %d on ",min);
if(a==min){count=1; printf("Sunday");}
if(b==min)
{
if (count==1)
{printf(" and ");}
else
{ count=1;}
printf(" Monday");
}
if(c==min)
{
if (count==1)
{printf(" and ");}
else
{ count=1;}
printf(" Tuesday");
}
if(d==min)
{
if (count==1)
{printf(" and ");}
else
{ count=1;}
printf(" wednesday");
}
if(e==min)
{
if (count==1)
{printf(" and ");}
else
{ count=1;}
printf(" Thursday");
}
if(f==min)
{
if (count==1)
{printf(" and ");}
else
{ count=1;}
printf(" Friday");
}
if(g==min)
{
if (count==1)
{printf(" and ");}
else
{ count=1;}
printf(" Saturday");
}
} // end of main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.