Program for arithmetic operations

Source: Internet
Author: User

# Define destdio. h
# Define demath. h
# Includewindows. h
Int right = 0;
Int wrong = 0;
Void add ()
{
Int A, B, C;
A = rand () % 100;
B = rand () % 100;
Printf ("Please answer: \ n \ t % d + % d =", a, B );
Scanf ("% d", C );
If (a + B = C)
{
Printf ("correct answer! \ 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 % d-% d =", a, B );
Scanf ("% d", C );
If (a-B = C)
{
Printf ("correct answer! \ 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 % d * % d =", a, B );
Scanf ("% d", C );
If (A * B = C)
{
Printf ("correct answer! \ 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 % d/% d =", a, B );
Scanf ("% d", C );
If (A/B = C)
{
Printf ("correct answer! \ N ");
Right ++;
}
Else
{
Printf ("Answer error! \ N ");
Wrong ++;
}
}
Void main ()
{
Int choise;
Int con = 0;
Printf ("\ n \ t welcome to elementary school simple four arithmetic \ n ");
While (1)
{
Printf ("select \ n ");
Printf ("\ t addition operation (enter 1) \ n ");
Printf ("\ t subtraction operation (enter 2) \ n ");
Printf ("\ t multiplication (enter 3) \ n ");
Printf ("\ t Division (enter 4) \ n ");
Printf ("\ t exit the operation (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 continue operation? (Enter 1) \ n ");
Printf ("\ n \ t reselect? (Enter 2) \ n ");
Printf ("\ n \ t exit the operation? (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 !, The command you entered is incorrect! Enter again! \ N ");
}
Printf ("You have completed % d question \ n correct % d question \ n error % d question \ n", right + wrong, right, wrong );
}

Program for arithmetic operations

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.