I need some simple help. I have created this program code that I will show. Here is the problem. The first time through, in the middle of the program it asks for a new number. When you enter the number, it stays that number through the loops. How do I get it to pause and ask the question (iRoll) and read in the new answer each time through the loop? Also, I set it to shut the loop off if you type in "n" at the end; however, it runs the program one more time before shutting down.
I need some help with this as it is probably a simple error, but I'm just a beginner.
*********************************************************************************************
* Name: Date Assigned: 10-16-08
* Course: CSE 1233 Date Due: 10-23-08
*
* File Name: psk29lab5.h
*
* Program Objective: To develop a game using random numbers that represent 1-6 on die and to
* have different values for different combinations.
*********************************************************************************************/
#include<stdio.h>
#include<stdlib.h>
int main()
{
char cYesNo = '\0';
char cRoll = '\0';
int iRoll = 0;
int iRandom1 = 0;
int iRandom2 = 0;
int iRandom3 = 0;
int iRandom4 = 0;
int iRandom5 = 0;
int iRandom6 = 0;
int iScore = 0;
int iScore2 = 0;
int iTotal1 = 0;
int iTotal2 = 0;
srand(time());
system("clear");
printf("Welcome to a game of Quispe. You and the computer will each roll two dice\n");
printf("to determine the winner. There is an option for a re-roll of one die if\n");
printf("the user so desires. A one and a two on the die will result in a Quispe.");
printf("\n1000 points will be awarded for a Quispe. If doubles are rolled, the points\n");
printf("will be added by multiplying the number on the die by 110. If you have two\n");
printf("different numbers, the first die will be multipled by ten and then the second\n");
printf("die number will be added to it. The highest point total wins the game.");
Please use [code][/code] tags and indentation next time :)
Anyway, it seems somewhat strange that it would do that...you could try turning to loop into just a normal while loop, since cYesNo is != 'n' at the beginning of the program.
And to solve the other problem, you either need to ask each time you want them to be able to change the roll, or you could try just making a function that generates the 2 random numbers and does everything you need to.