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

Please indicate what is wrong in the code and why ? #include <stdio.h> #include

ID: 2995558 • Letter: P

Question

Please indicate what is wrong in the code and why ?

#include <stdio.h>

#include <stdlib.h>

int main()

{

    float far, cent ;

    printf(" Enter cent: ") ; //enter the value of cent

    scanf("%f", &cent)

    far=9.0*cent/5.0 + 32.0 ;

    printf(" far = %d", far);

return 0;

}

#include <stdio.h>

#include <stdlib.h>

int main()

{

    float far, cent ;

    printf(" Enter cent: ") ; //enter the value of cent

    scanf("%f", &cent)

    far=9.0*cent/5.0 + 32.0 ;

    printf(" far = %d", far);

return 0;

}

Explanation / Answer

There is a ';' missing after scanf statement.

Also, as far is a float, while printing you have to use %f instead of %d.

The correct code is:

#include <stdio.h>

#include <stdlib.h>

int main()

{

float far, cent ;

printf(" Enter cent: ") ; //enter the value of cent

scanf("%f", &cent);

far=9.0*cent/5.0 + 32.0 ;

printf(" far = %f", far);

return 0;

}