Hi guys!
Can anyone tell what's wrong with that?
Hi guys!
Can anyone tell what's wrong with that?
Else statements do not need the conditional section
on line 27 you have else (condition), you need to either change it to else if, or get rid of the (condition) portion.
Code:int get_random_number(void) { return 4; //chosen by fair dice roll. //guaranteed to be random }
And now i find another issue Everything will work except prinf phrases. When i insert one number it woun't tell me if i win or not.
Why are you posting a C question in the C++ forum?
Post code inside of code tags rather than a screen shot of your editor. Then we can compile and run your program, which would help diagnose the problem.
Ask yourself this question
How can a single number be both larger than a number AND smaller than the same number?
Code:int get_random_number(void) { return 4; //chosen by fair dice roll. //guaranteed to be random }
So I made changes
Is this right or should i use || ?
Code:#include <stdio.h> #include <stdlib.h> #include <time.h> int main (void) { int number, jackpot; srand (time(NULL)); printf ("Insert one number between 1-100: "); scanf ("%d", &number); if (number > jackpot +10 && number < jackpot -20) { printf("Win is close!"); } else if (number > number +5 && number < jackpot -10) { printf("Congratulations, You have won small price!"); } else if (number > jackpot +11 && number < jackpot -22) { printf("You haven't won anything!"); } else if (number==jackpot) { printf("JACKPOT!"); } return 0; }
Hi guys!
Can someone tell me how or what i must fix if...else statement that printf will work??
Code:#include <stdio.h> #include <stdlib.h> #include <time.h> int main (void) { int number, jackpot; srand (time(NULL)); printf ("Insert one number between 1-100: "); scanf ("%d", &number); if (number > jackpot +10 && number < jackpot -20) { printf("Win is close!"); } else if (number > number +5 && number < jackpot -10) { printf("Congratulations, You have won small price!"); } else if (number > jackpot +11 && number < jackpot -22) { printf("You haven't won anything!"); } else if (number==jackpot) { printf("JACKPOT!"); } return 0; }
What are you initializing jackpot to begin with?
When i start that game, program must generate one number.(Jackpot number)
Then comes the question and i must insert one number between 1 and 100.
If..else block:
#1 If my picked number different is +-10 from jackpot number, then program must print that "win is close!".
#2 If my picked number different is +-5 from jackpot number, then program must print that "Congratulations, You have won small price!".
#3 if my picked number is not #1 and #2 then program must print "You haven't won anything!"
#4 If my picked number is jackpot number then program must print "JACKPOT!"