Click here to Skip to main content
15,895,656 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Updated program-having a pointer error Pin
kbury4-Nov-09 3:41
kbury4-Nov-09 3:41 
GeneralRe: Updated program-having a pointer error Pin
Tim Craig4-Nov-09 13:55
Tim Craig4-Nov-09 13:55 
AnswerRe: Updated program-having a pointer error Pin
David Crow4-Nov-09 3:55
David Crow4-Nov-09 3:55 
GeneralRe: Updated program-having a pointer error Pin
kbury4-Nov-09 4:09
kbury4-Nov-09 4:09 
GeneralRe: Updated program-having a pointer error Pin
Ibrahim Bello4-Nov-09 4:18
Ibrahim Bello4-Nov-09 4:18 
GeneralRe: Updated program-having a pointer error Pin
softwaremonkey4-Nov-09 8:29
softwaremonkey4-Nov-09 8:29 
GeneralRe: Updated program-having a pointer error Pin
Ibrahim Bello4-Nov-09 9:50
Ibrahim Bello4-Nov-09 9:50 
GeneralRe: Updated program-having a pointer error Pin
David Crow4-Nov-09 4:24
David Crow4-Nov-09 4:24 
I figured it would. You might consider formatting your code (e.g., using spaces instead of tabs) so that errors such as mismatched braces would be more obvious. For example:

#define SENT 4 //"Quit" menu choice
  
/*  Display Title and Menu */
void DisplayMenu (void)
{
    printf("MENU OF OPERATIONS\n");
    printf("1. Addition.\n");
    printf("2. Subtraction.\n");
    printf("3. Multiplication.\n");
    printf("4. Quit.\n\n");
}
  
/* Get Menu Choice */
int GetMenuChoice (void)
{
    int c;
      
    do
    {
        printf ("Enter the number of the operation to try (1-4):\n");
        scanf ("%d", &c);
        if  (c<1 || c>SENT)
            printf("\aInput value is out of range.\n");
    } while (c < 1 || c > SENT);
  
    return (c);
}
  
/* Generate and return 2 integers between 2-12 inclusive */
void Gen2Rand (int*r1p, int*r2p)
{
    int r1; //First random number
    int r2; //Second random number
  
    r1 = 2 + rand() % 11;
    r2 = 2 + rand() % 11;
  
    *r1p = r1;
    *r2p = r2;
}
  
/* Display two random numbers and ask user what the answer would be after the chosen operation*/
void DrillOneProb (int c, int r1, int r2)
{
    int CorAns, //Correct Answer
        Reply;  // Users Reply
  
    switch (c)
    {
        case 1:
            printf("+");
            CorAns = r1 + r2;
            break;
  
        case 2:
            printf("-");
            CorAns = r1 - r2;
            break;
  
        default:
            printf("x");
            CorAns = r1 * r2;
            break;
    }
  
    printf(" %d, ?", Reply);
    scanf ("%d", &Reply);
    if (Reply == CorAns)
        printf("Yes, that is correct. Good Job!");
    else
    {
        printf("No, the correct answer is: %d", CorAns);
        printf("\n\n");
    }
}
  
int main (void)
{
    int   c;   //Menu Choice (1-4)
    int   r1,  //First Random Integer:  2-12 inclusive
          r2;  //Second Randon Integer:  2-12 inclusive
  
    DisplayMenu();
    c = GetMenuChoice();
    while (c >= 1 && c < SENT)
    {
        Gen2Rand (&r1, &r2);
        DrillOneProb (c, r1,r2);
        DisplayMenu();
        c = GetMenuChoice();
        printf("Program Complete\n");
    }
  
    return (0);
}


"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons


GeneralRe: Updated program-having a pointer error Pin
kbury4-Nov-09 5:08
kbury4-Nov-09 5:08 
QuestionProblem reading from text file Pin
Ibrahim Bello4-Nov-09 3:22
Ibrahim Bello4-Nov-09 3:22 
AnswerRe: Problem reading from text file Pin
David Crow4-Nov-09 3:51
David Crow4-Nov-09 3:51 
AnswerRe: Problem reading from text file Pin
«_Superman_»4-Nov-09 3:56
professional«_Superman_»4-Nov-09 3:56 
GeneralRe: Problem reading from text file Pin
Ibrahim Bello4-Nov-09 4:22
Ibrahim Bello4-Nov-09 4:22 
AnswerRe: Problem reading from text file Pin
krmed4-Nov-09 7:09
krmed4-Nov-09 7:09 
GeneralRe: Problem reading from text file Pin
Ibrahim Bello4-Nov-09 9:31
Ibrahim Bello4-Nov-09 9:31 
GeneralRe: Problem reading from text file Pin
David Crow4-Nov-09 9:44
David Crow4-Nov-09 9:44 
GeneralRe: Problem reading from text file Pin
Ibrahim Bello9-Nov-09 2:02
Ibrahim Bello9-Nov-09 2:02 
Questionload image Pin
Arefeh Haghpnah4-Nov-09 3:22
Arefeh Haghpnah4-Nov-09 3:22 
AnswerRe: load image Pin
David Crow4-Nov-09 3:33
David Crow4-Nov-09 3:33 
QuestionCan't create new project in VS 6.0 Pin
ephe4-Nov-09 3:09
ephe4-Nov-09 3:09 
QuestionHow do you profile your C++ code ? Pin
Ahmed Charfeddine4-Nov-09 2:04
Ahmed Charfeddine4-Nov-09 2:04 
Questionis it possible to genarate barcode application using vc++6.0 Pin
eswar pothula4-Nov-09 0:42
eswar pothula4-Nov-09 0:42 
AnswerRe: is it possible to genarate barcode application using vc++6.0 Pin
Jan Sommer4-Nov-09 1:46
Jan Sommer4-Nov-09 1:46 
AnswerRe: is it possible to genarate barcode application using vc++6.0 [modified] Pin
Code-o-mat4-Nov-09 2:22
Code-o-mat4-Nov-09 2:22 
QuestionApplication that communicates with a database - how? Pin
Jan Sommer4-Nov-09 0:32
Jan Sommer4-Nov-09 0:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.