Click here to Skip to main content
15,843,865 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: A General Problem Pin
«_Superman_»29-Oct-09 10:04
professional«_Superman_»29-Oct-09 10:04 
GeneralRe: A General Problem Pin
WindowsVsLinux29-Oct-09 19:03
WindowsVsLinux29-Oct-09 19:03 
QuestionRe: A General Problem Pin
David Crow29-Oct-09 10:30
David Crow29-Oct-09 10:30 
AnswerRe: A General Problem Pin
WindowsVsLinux29-Oct-09 19:05
WindowsVsLinux29-Oct-09 19:05 
AnswerRe: A General Problem Pin
enhzflep29-Oct-09 10:36
enhzflep29-Oct-09 10:36 
GeneralRe: A General Problem Pin
WindowsVsLinux29-Oct-09 19:08
WindowsVsLinux29-Oct-09 19:08 
GeneralRe: A General Problem Pin
Adam Roderick J29-Oct-09 19:21
Adam Roderick J29-Oct-09 19:21 
Questionpointer and switch Pin
kbury29-Oct-09 9:18
kbury29-Oct-09 9: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 9:21
professional«_Superman_»29-Oct-09 9:21 
GeneralRe: pointer and switch Pin
kbury29-Oct-09 9:24
kbury29-Oct-09 9:24 
AnswerRe: pointer and switch Pin
CPallini29-Oct-09 11:58
mveCPallini29-Oct-09 11:58 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 3:31
kbury30-Oct-09 3:31 
GeneralRe: pointer and switch Pin
CPallini30-Oct-09 3:52
mveCPallini30-Oct-09 3:52 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 10:37
kbury30-Oct-09 10:37 
GeneralRe: pointer and switch Pin
CPallini30-Oct-09 11:43
mveCPallini30-Oct-09 11:43 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 11:57
kbury30-Oct-09 11:57 
GeneralRe: pointer and switch Pin
CPallini30-Oct-09 12:00
mveCPallini30-Oct-09 12:00 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 12:05
kbury30-Oct-09 12:05 
GeneralRe: pointer and switch Pin
kbury30-Oct-09 12:06
kbury30-Oct-09 12:06 
GeneralRe: pointer and switch Pin
CPallini30-Oct-09 12:23
mveCPallini30-Oct-09 12:23 
Questionhow to fit the result application from WinExec() in a splitter window? Pin
Member 333413529-Oct-09 9:01
Member 333413529-Oct-09 9:01 
AnswerRe: how to fit the result application from WinExec() in a splitter window? Pin
«_Superman_»29-Oct-09 9:13
professional«_Superman_»29-Oct-09 9:13 
GeneralRe: how to fit the result application from WinExec() in a splitter window? Pin
Member 333413530-Oct-09 3:26
Member 333413530-Oct-09 3:26 
QuestionConverting data from TextBox (String^) to string Pin
iMikki29-Oct-09 8:22
iMikki29-Oct-09 8:22 
AnswerRe: Converting data from TextBox (String^) to string Pin
transoft29-Oct-09 8:32
transoft29-Oct-09 8: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.