+ 2
I'm confusing about this!
Complete the expression so that userPoints is assigned with 0 if userLevel is greater than 30 (second branch). Otherwise, userPoints is assigned with 10 (first branch).
4 Respostas
+ 6
Altesse
Next time, save your code in the code playground and share it's link here so it'll be easy to run it
You should assign 0 to user points if user level is > 30. In your if condition, you used userPoints instead is userLevel, so it always assigns 10 to userPoints. Also, your if condition should be userLevel<=30 and not userLevel<30
+ 3
Ohh yea, thank you!
+ 2
my code is
#include <stdio.h>
int main(void) {
int userLevel;
int userPoints;
scanf("%d", &userLevel); // Program will be tested with values: 29, 30, 31, 32.
userPoints = 0;
if (userPoints < 30) {
userPoints = 10;
}
else {
userPoints = 0;
}
printf("%d\n", userPoints);
return 0;
}
+ 1
the first 2 # worked but not the last 2 #