The program experience of automatically generating arithmetic in primary school

Source: Internet
Author: User

#include <stdio.h>
#include <math.h>
#include <windows.h>
int right=0;
int wrong=0;
void Add ()
{
int a,b,c;
A=rand ()%100;
B=rand ()%100;
printf ("Please answer: \n\t\t%d +%d =", A, b);
scanf ("%d", c);
if (a+b==c)
{
printf ("Answer right!\n");
right++;
}
Else
{
printf ("Answer error!\n");
wrong++;
}
}
void Minu ()
{
int a,b,c;
A=rand ()%100;
B=rand ()%100;
printf ("Please answer: \n\t\t%d-%d =", A, b);
scanf ("%d", c);
if (a-b==c)
{
printf ("Answer right!\n");
right++;
}
Else
{
printf ("Answer error!\n");
wrong++;
}
}
void Mul ()
{
int a,b,c;
A=rand ()%100;
B=rand ()%100;
printf ("Please answer: \n\t\t%d *%d =", A, b);
scanf ("%d", c);
if (a*b==c)
{
printf ("Answer right!\n");
right++;
}
Else
{
printf ("Answer error!\n");
wrong++;
}
}
void Di ()
{
int a,b,c;
A=rand ()%100;
B=rand ()%100;
printf ("Please answer: \n\t\t%d/%d =", A, b);
scanf ("%d", c);
if (a/b==c)
{
printf ("Answer right!\n");
right++;
}
Else
{
printf ("Answer error!\n");
wrong++;
}
}
void Main ()
{
int choise;
int con=0;
printf ("\n\t\t\t Welcome to primary School simple arithmetic \ n");
while (1)
{
printf ("Please select: \ n");
printf ("\t\t\t addition operation (Please enter 1) \ n");
printf ("\t\t\t subtraction operation (Please enter 2) \ n");
printf ("\t\t\t Multiplication (Please enter 3) \ n");
printf ("\t\t\t Division operation (Please enter 4) \ n");
printf ("\t\t\t exit operation (Please enter 5) \ n");
if (con==0)
scanf ("%d", choise);
Switch (choise)
{
Case 1:
Add ();
Break
Case 2:
Minu ();
Break
Case 3:
Mul ();
Break
Case 4:
Di ();
Break
Case 5:
Return
}
printf ("\n\t\t\t continue operation?") (Please enter 1) \ n ");
printf ("\n\t\t\t re-selected?" (Please enter 2) \ n ");
printf ("\n\t\t\t exit operation?") (Please enter 3) \ n ");
scanf ("%d", con);
if (con==1)
Con=1;
else if (con==2)
con=0;
else if (con==3)
Break
Else
printf ("Sorry!, you entered the wrong command!" Please re-enter!\n ");
}

printf ("You have completed%d questions \ nthe correct%d \ n error%d \ n", Right+wrong,right,wrong);
}

This program, can automatically generate elementary school simple arithmetic, provide the menu lets the user choose, then Judge subtraction, judge correct answer wrong number of questions, users can also choose to continue to answer the question or re-select or quit the program.

The system is to allow the computer to act as an arithmetic teacher to assign homework to the small students, to give the students a quiz,
The system should have the following functions:
1. For elementary school students (respectively, the +,-, *, ÷ and other different operations) 2. After the student has done the question, carries on the appraisal;
After each of the students to do a question, the review gives "correct answer, very good" or "answer wrong, redo" and other words;
3. Add, subtract, multiply, divide operation function can choose to realize freely;

When we design the program, we divide a big problem into several modules, use different functions to design the modules separately, and then use the function call, we can associate these different modules together.

During the design process, I originally defined the variable flag is a character type, when input y continue to do the next question, enter n when the system, I found that no matter which letter, in the view of the results found that there are two continue testing please press 1, exit test press 0: statement output, and then after the teacher's explanation I understand, In a contiguous 2 scanf function, when entering the first scanf function as a character, the enter key is stored as a character in the second scanf function.

Know that their technical level is not high, such procedures encountered a lot of difficulties, but I believe that through the future of continuous learning, my ability to become a great improvement.

The program experience of automatically generating arithmetic in primary school

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.