i should write a program help an elementary school student learn addition, subtraction,
division, multiplication.
the user choose the operation (An option of 1 means
addition problems only, 2 means subtraction problems only, 3 means multiplication
problems only and 4 means a random mixture of all these types, 5 for a combination of 1
through 4)
The student then inputs the answer. Next, the program checks the student’s answer. If it’s
correct, display the message "Very good!" and ask another multiplication question. If the
answer is wrong, display the message "No. Please try again." and let the student try the
same question repeatedly until the student finally gets it right.
any way out put must be

& i write a program but it doesn't work
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
int menu (void);
void arithmetic (void);
void correctMessege (void);
void incorrectMessege (void);
int main (void)
{
int num1,num2;
int operation;
int result;
srand( (unsigned int)time( 0 ) );
menu ();
scanf("%d", &operation );
arithmetic ();
if ( num1*num2 !=result || num1+num2 !=result || num1-num2 !=result || num1/num2 !=result )
{
incorrectMessege ();
}
if ( num1*num2 ==result || num1+num2 ==result || num1-num2 ==result || num1/num2 ==result )
{
correctMessege ();
}
getch ();
return 0;
}
int menu (void)
{
printf("Enter: 1 for addition, 2 for subraction\n");
printf("Enter: 3 for multiplication, 4 for division\n");
printf("Enter: 5 for combination of 1 throgh 4\n");
printf("?");
return 0;
}
void arithmetic (void)
{
int num1;
int num2;
int operation;
int result;
int answer;
num1 = rand() % 10;
num2 = rand() % 10;
if (operation == 1) {
result = num1 + num2;
printf("How much is %d + %d?\n", num1, num2);
scanf_s("%d",& answer);
}
else if (operation == 2) {
result = num1 - num2;
printf("How much is %d - %d?\n", num1, num2);
scanf_s("%d",& answer);
}
else if (operation == 3) {
result = num1 * num2;
printf("How much is %d * %d?\n", num1, num2);
scanf_s("%d",& answer);
} else if (operation == 4) {
result = num1 / num2;
printf("How much is %d / %d?\n", num1, num2);
scanf_s("%d",& answer);
}
return ;
}
void correctMessege (void){
switch ( 1+rand()%4 )
{
case 1:
printf( "Very good!");
break;
case 2:
printf( "Excellent!");
break;
case 3:
printf( "Nice work!");
break;
case 4:
printf( "Keep up the good work!");
break;
}
}
void incorrectMessege (void)
{
switch ( 1+rand()%4 )
{
case 0:
printf( "No. Please try again.");
break;
case 1:
printf( "Wrong. Try once more.");
break;
case 2:
printf( "Don't give up!");
break;
case 3:
printf( "No. Keep trying.");
break;
}
}
what can i do ????
This post has been edited by r.stiltskin: 26 April 2012 - 02:11 PM
Reason for edit:: Added code tags. Please learn to use them.

New Topic/Question
Reply



MultiQuote
is an opening code tag. The whole thing. A pair of brackets [ ] with the word code between them. This tag goes before your code.
is a closing code tag. A pair of brackets [ ] with /code inside. This tag goes after your code.




|