s. Read the following code. For each of the provided example values of category
ID: 3870676 • Letter: S
Question
Explanation / Answer
5.
#include <stdio.h>
int main(void) {
int rate=20;
double total=100;
char category;
printf("Enter the letter of your category");
scanf("%c",&category);
switch(category)
{
case 'M':
rate=rate+1;
case 'F':
total=rate*2;
break;
case 'H':
case 'D':
rate=(int)(total/8);
break;
default:
total=total+rate;
break;
}
printf(" Final value of total %f",total);
printf(" Final value of rate %d",rate);
return 0;
}
Output:
6.
#include <stdio.h>
int main(void) {
int rate=20;
double total=100;
char category;
printf("Enter the letter of your category");
scanf("%c",&category);
if(category=='M')
{
rate=rate+1;
total=rate*2;
}
else if(category=='F')
{
total=rate*2;
}
else
{
total=total+rate;
}
printf(" Final value of total %f",total);
printf(" Final value of rate %d",rate);
return 0;
}
Output:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.