Re-type the code and fix any errors. The code should convert non-positive numbers to 1.

if (userNum > 0) printf("Positive.\n"); else printf("Non-positive, converting to 1.\n"); userNum = 1; printf("Final: %d\n", userNum);

Respuesta :

Answer:

if (userNum > 0)

{

printf("Positive.\n");

}

else

{ printf("Non-positive, converting to 1.\n");

userNum = 1;

printf("Final: %d\n", userNum);

}

Explanation:

Paranthesis was missing in the mentioned code. If else statement always nest inside paranthesis in C language. Please note that the above code will also convert not only negative numbers but also 0 to 1!

ACCESS MORE