Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Correct/Rewrite the code int double n = 5, fact = 1: for(int 1 = n: 1 = 1: 1 +)

ID: 2246356 • Letter: C

Question


Correct/Rewrite the code int double n = 5, fact = 1: for(int 1 = n: 1 = 1: 1 +) fact 1: printf" Factorial la: fact case{"d", set1 switch let1) code "a": code "b": print "red" case "c" print "blue" case "d" print "green" case "e" print "yellow" print(") The program intention is to initialize the array n with 1, 2, 3, 4, 5 int n[]: for(int I = 1: 35J fee = 20.0 else if (speed > 50) fee = 40.000: else if (speed > 75) fee = 60.00: Rewrite the following code using while int count = 0: for(int I = 0: 1

Explanation / Answer

1.

int main(){

double n=5,fact=1;

for(int i=n;i>=1;i--)

fact*=i;

printf("factorial is: %.2f ",fact);

}

2.

scanf("%c",&ctl);

switch(ctl){

case 'a':

case 'b':

printf("red ");

case 'c':

printf("blue ");

case 'd':

printf("green ");

case 'e':

printf("yellow");

}

printf(" ");

3.

int main(){

int n[5];

for(int i=0;i<5;i++)

n[i]=i+1;

}

4.

switch(speed) {

case 0:

case 1:

case 2:

.

.

.

case 35:

fee=0;

break;

case 36:

case 37:

.

.

.

case 50:

fee=20;

break;

case 51:

case 52:

.

.

.

case 75:

fee=40;

break;

default:

fee=60;

  

}

5.

int count=0, i=0;

while(i<n){

printf("%d ", count) ;

++count;

i++;

}