Click here to Skip to main content
15,902,276 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: A General Problem Pin
«_Superman_»29-Oct-09 9:04
professional«_Superman_»29-Oct-09 9:04 
GeneralRe: A General Problem Pin
WindowsVsLinux29-Oct-09 18:03
WindowsVsLinux29-Oct-09 18:03 
QuestionRe: A General Problem Pin
David Crow29-Oct-09 9:30
David Crow29-Oct-09 9:30 
AnswerRe: A General Problem Pin
WindowsVsLinux29-Oct-09 18:05
WindowsVsLinux29-Oct-09 18:05 
AnswerRe: A General Problem Pin
enhzflep29-Oct-09 9:36
enhzflep29-Oct-09 9:36 
GeneralRe: A General Problem Pin
WindowsVsLinux29-Oct-09 18:08
WindowsVsLinux29-Oct-09 18:08 
GeneralRe: A General Problem Pin
Adam Roderick J29-Oct-09 18:21
Adam Roderick J29-Oct-09 18:21 
Questionpointer and switch Pin
kbury29-Oct-09 8:18
kbury29-Oct-09 8:18 
I am trying to write a program as a math tutor. Can someone look at this code. I keep getting errors on int and pointer as well as telling me the switch case has illegal pointer.

Thanks, any advice would be greatful.

#include <stdio.h>
#include <stdlib.h>


#define SENT 4 //"Quit" menu choice


/*  Function Prototypes */


	void DisplayMenu (void);
	void GetMenuChoice (void);
	void Gen2Rand (int*r1, int*r2);
	void DrillOneProb (int*c, int*r1, int*r2);






/*============Mainline Procedures===============*/

int main (void)
{
	int	   c;   //Menu Choice (1-4)
	int   r1,  //First Random Integer:  2-12 inclusive
	      r2;  //Second Randon Integer:  2-12 inclusive


}

/*===========CHILD FUNCTIONS===============*/

/*  Display Title and Menu */

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");

    }


/* Get Menu Choice */

void GetMenuChoice (void)

	{
		int c;
		printf ("Enter the number of the operation to try (1-4):\n");
		scanf ("%d", &c);
		while
			 (c<1 || c>SENT)
				printf("\aInput value is out of range.\n");


	}

/* Generate and return 2 integers between 2-12 inclusive */

void Gen2Rand (int *r1p, int *r2p)

	{
		int c;
		c=0;

		if (c>=1 && c<SENT)

		int r1; // First random number
		int r2; //Second random number

		r1 = 2 + rand() %11;
		r2 = 2 + rand() %11;

	   *r1p = r1;
	   *r2p = r2;

	   printf("Program complete\n");

	}

/* 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

			{
			printf("\nWhat is %d", & r1);

			r1 = 2 + rand() % 11;
			}


	switch (c);
	{
		case '1':  1 = +; break;
		CorAns = r1 + r2;

		case '2':  2 = -; break;
		CorAns = r1 - r2;

		case '3':  3 = x; break;
		CorAns = r1 x r2;

	}

	printf("%d ?  %d\n", r2, Reply);

   if
  		Reply = CorAns
	   		{
			   printf("Yes, that is correct. Good Job!");
			}

		else
			printf("No, the correct answer is: %d", CorAns);
			printf("\n\n");

return (c);




    print_menu(); //Print the menu option, and configure some needed things.


    return (0); //The end of our simple game.

AnswerRe: pointer and switch Pin
«_Superman_»29-Oct-09 8:21
professional«_Superman_»29-Oct-09 8:21 
GeneralRe: pointer and switch Pin
kbury29-Oct-09 8:24
kbury29-Oct-09 8:24 
AnswerRe: pointer and switch Pin
CPallini29-Oct-09 10:58
mveCPallini29-Oct-09 10:58 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 2:31
kbury30-Oct-09 2:31 
GeneralRe: pointer and switch Pin
CPallini30-Oct-09 2:52
mveCPallini30-Oct-09 2:52 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 9:37
kbury30-Oct-09 9:37 
GeneralRe: pointer and switch Pin
CPallini30-Oct-09 10:43
mveCPallini30-Oct-09 10:43 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 10:57
kbury30-Oct-09 10:57 
GeneralRe: pointer and switch Pin
CPallini30-Oct-09 11:00
mveCPallini30-Oct-09 11:00 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 11:05
kbury30-Oct-09 11:05 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 11:06
kbury30-Oct-09 11:06 
GeneralRe: pointer and switch Pin
CPallini30-Oct-09 11:23
mveCPallini30-Oct-09 11:23 
Questionhow to fit the result application from WinExec() in a splitter window? Pin
Member 333413529-Oct-09 8:01
Member 333413529-Oct-09 8:01 
AnswerRe: how to fit the result application from WinExec() in a splitter window? Pin
«_Superman_»29-Oct-09 8:13
professional«_Superman_»29-Oct-09 8:13 
GeneralRe: how to fit the result application from WinExec() in a splitter window? Pin
Member 333413530-Oct-09 2:26
Member 333413530-Oct-09 2:26 
QuestionConverting data from TextBox (String^) to string Pin
iMikki29-Oct-09 7:22
iMikki29-Oct-09 7:22 
AnswerRe: Converting data from TextBox (String^) to string Pin
transoft29-Oct-09 7:32
transoft29-Oct-09 7: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.