Automatic generation of primary arithmetic topics

Source: Internet
Author: User
Tags mul

Main function: Operation primary arithmetic, can choose subtraction and mixed operation.

Design idea: First of all, think about the range of arithmetic, consider the arithmetic ability of elementary school students, then classify operation method, divide into subtraction mixed operation,

Then you can choose whether to continue to do or quit the program, you can summarize the correct or wrong number of questions, convenient calculation and wrong number of problems.

Source:

/*Primary Arithmetic*/#include<stdio.h>#include<stdlib.h>#include<time.h>intright=0, wrong=0;inta,b,c,d;/*addition Operation*/voidAdd () {inti,j;  for(i=0;i<5; i++) {a=rand ()% -;//rand () produces a random function with a distribution range of 0 to the largest integer, resulting in an integer of 1-49B=rand ()% -; printf ("please answer:%d+%d=", A, b); scanf ("%d",&j); if(a+b==j) {printf ("answer right \ n"); Right++; }            Else{printf ("answer error \ n"); Wrong++; }        Continue; }}/*Subtraction Operations*/voidMinu () {inti,j;  for(i=0;i<5; i++) {a=rand ()% -;//rand () produces a random function with a distribution range of 0 to the largest integer, resulting in an integer of 1-49B=rand ()% -; printf ("please answer:%d-%d=", A, b); scanf ("%d",&j); if(a-b==j) {printf ("answer right \ n"); Right++; }            Else{printf ("answer error \ n"); Wrong++; }            Continue; }}/*Multiplication Operations*/voidMul () {inti,j;  for(i=0;i<5; i++) {a=rand ()% -;//rand () produces a random function with a distribution range of 0 to the largest integer, resulting in an integer of 1-49B=rand ()% -; printf ("please answer:%d*%d=", A, b); scanf ("%d",&j); if(a*b==j) {printf ("answer right \ n"); Right++; }            Else{printf ("answer error \ n"); Wrong++; }            Continue; }}/*Division Operation*/voiddi () {inti,j;  for(i=0;i<5; i++) {a=rand ()% -;//rand () produces a random function with a distribution range of 0 to the largest integer, resulting in an integer of 1-49B=rand ()% -; printf ("please answer:%d/%d=", A, b); scanf ("%d",&j); if(a/b==j) {printf ("answer right \ n"); Right++; }            Else{printf ("answer error \ n"); Wrong++; }            Continue; }}/*Mixed Operations*/voidHunhe () {inti,j;  for(i=0;i<5; i++) {a=rand ()% -;//rand () produces a random function with a distribution range of 0 to the largest integer, resulting in an integer of 1-49B=rand ()% -; C=rand ()% -; D=rand ()% -; printf ("please answer:%d+%d-%d*%d=", a,b,c,d); scanf ("%d",&K); if(a+b==j) {printf ("answer right \ n"); Right++; }            Else{printf ("answer error \ n"); Wrong++; }            Continue; }}voidMain () {printf ("Welcome to elementary School arithmetic \ n");  while(1)        {                intcon=0, choose=0; printf ("Please select: \ n"); printf ("Add Operation Please enter (1) \ n"); printf ("Subtraction Operation Please enter (2) \ n"); printf ("multiplication Operation please input (3) \ n"); printf ("Division Operation Please enter (4) \ n"); printf ("Mixed Operation please input (5) \ n"); if(con==0) scanf ("%d",&choose); Switch(choose) { Case 1: Add (); Break;  Case 2: Minu (); Break;  Case 3: Mul (); Break;  Case 4: Di (); Break;  Case 5: Hunhe (); Break; } printf ("\ n re-select? Please enter (1) \ n"); printf ("\ nthe exit operation? Please enter (2) \ n"); scanf ("%d",&con); if(con==1) Con=1; if(con==2)                 Break; } printf ("you've completed%d questions \ nthe correct%d \ n error%d \ n", right+wrong,right,wrong);}

Program run:

Summary: Through this assignment, I think my knowledge of C language is still a bit poor foundation, I ask classmates, partners, ask them to help me, ask a lot of questions, also and classmates borrowed books, to consolidate their professional knowledge, I also through the network to find code, to make changes, on these basis, Have my this homework, also through this homework, let me have a plan and goal, to study these professional knowledge, and students to do a little more exchanges, to make up for my own shortcomings, but also through this homework to understand their weak point, to put their own will not be the place will be, a lot of learning, saving, Browse the books in this area. Finish this homework, just understand the programming is not easy, also very thank the students.

Automatic generation of primary arithmetic topics

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.