So I'm working on a problem from a midterm that I know I completely messed up but i'm trying to understand it but I'm having a difficult time
The major part i'm having issues is in C we are using functional programming. Now I wrote a function that I think should work but I don't think i'm calling it correctly. Basicly when i want to use a printf statement call the function and produce the number.
Any help would be nice so I can get passed this point.
Here is what I have done so far, and any questions on what i'm trying to do just ask
The major part i'm having issues is in C we are using functional programming.
Well, that would certainly be interesting.
diceRoll is not the same as diceroll.
main should return type int.
srand should be invoked one time, so it should probably be invoked in main and not diceroll.
What role do you see dealRoll playing here? diceroll does nothing with the value fed to it and it seems to serve no purposed in main other than as fodder to be fed to diceroll.
thought I would try to clean up/shorten what you have and call the function it looked like you wanted to call:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int DiceRoll() {
return (rand()%6+1)+(rand()%6+1);
}
int main() {
int choice;
srand(time(0));
printf("Enter in the bet you want: under 7 (Enter 1), over 7 (Enter 2), for 7 (Enter 3): ");
scanf("%i",&choice);
printf("Shake, Shake, the dealer rolls %d",DiceRoll());
system("pause");
}
I left line 10 and 13 because it looked like you plan on using them later in the program to tell the user if they win or not.
note: system("pause"); only works under windows as far as I know. doesn't work with Linux for sure.