115k views
3 votes
Print 'userNum1 is negative" if userNum1 is less than 0. End with newline Convert userNum2 to 0 if userNum2 is greater than 9. Otherwise, print "userNum2 is less than or equal to 9:. End with newline 3 int main(void) 4 int userNuml; S int userNum2; 6 7 userNum1-1; 8 userNum2 7 10 if (userNum1) printf "userNum1 is negative.n 12 13 if(userNum2-9 14 15 16 17 print f("userNum2 18 19 return ; printf("userNum2 is less than or equal to 9.\\; Your solution goes here is%d.\\", use rNur?); 20 Check Try again x A possible solution uses an if statement for userNum1, and an if-else statement for userNum2 x Testing for correct output for userNum 1 = 0 and userNum2 = 10 Output differs.

User JSantos
by
4.2k points

1 Answer

1 vote

Answer:

#include <stdio.h>

int main()

{

int userNum1;

int userNum2;

userNum1 = -1;

userNum2 = 7;

if (userNum1 < 0)

printf("userNum1 is negative. \\");

if(userNum2 > 9)

userNum2 = 0;

else

printf("userNum2 is less than or equal to 9.\\");

return 0;

}

Explanation:

Initialize userNum1 and userNum2.

If userNum1 is less than 0, print 'userNum1 is negative" and end with newline.

if userNum2 is greater than 9, assign 0 to userNum2.

Otherwise, print "userNum2 is less than or equal to 9 and end with newline.

User Yaobin Then
by
3.6k points