Hey guys, i'm getting an error that says "Undefined Reference to Gen2Rand" and i don't know how to fix that, also is there a way to declare my variables inside of my main rather than globally? thanks for helping
Code:
#include <stdlib.h>
#include <stdio.h>
#define SENT 4
int r1;
int r2;
int *r1p;
int *r2p;
int c;
void DisplayMenu (void);
int GetMenuChoice (void);
void Gen2Rand (int *r1p, int *r2p);
void DrillOneProb (int c, int r1, int r2);
/*==========>Main<==========*/
void main (void)
{
DisplayMenu();
GetMenuChoice();
while (c>=1 && c<SENT)
{
Gen2Rand(&r1, &r2);
DrillOneProb(c, r1, r2);
DisplayMenu();
GetMenuChoice();
}
printf("Program Complete.\n");
}
/*=====>DisplayMenu<=====*/
void DisplayMenu (void)
{
printf("MENU OF OPERATIONS\n\n");
printf("1. Addition.\n");
printf("2. Subtraction.\n");
printf("3. Multiplication.\n");
printf("4. Quit.\n\n");
}
/*====>GetMenuChoice<====*/
int GetMenuChoice (void)
{
int c;
do
{
printf("Enter the number of the operation to try (1-4): ");
scanf("%d", &c);
if(c<1 || c>SENT)
printf("\aInput value is out of range.\n");
}
while (c<1 || c>SENT);
return (c);
}
/*======>Get2Rand<=== ====*/
void Get2Rand (int *r1p, int *r2p)
{
int r1;
int r2;
r1= rand()%11 + 2;
r2= rand ()%11 + 2;
*r1p=r1;
*r2p=r2;
}
/*=====>DrillOneProb<=====*/
void DrillOneProb (c, r1, r2)
{
int CorAns;
int Reply;
printf("\nWhat is %d ", r1);
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? ", r2);
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");
}