Automatically generate four arithmetic applets for primary school students and four arithmetic applets

Source: Internet
Author: User

Automatically generate four arithmetic applets for primary school students and four arithmetic applets

Question requirements:

Write a program that can automatically generate the four arithmetic questions of primary school. After preliminary drafting of the functions to be implemented, estimate how long it will take. During programming, record how long it actually took.

 

C language source code:

# Include <stdio. h>
# Include <stdlib. h>
Main ()
{
Int n, a, B, c, d, e, f, g, h;
Printf ("[----------- Main Menu -----------] \ n ");
Printf ("---------- 1. Addition calculation question --------- \ n ");
Printf ("---------- 2. subtraction calculation question --------- \ n ");
Printf ("---------- 3. multiplication calculation question --------- \ n ");
Printf ("---------- 4. Division calculation question --------- \ n ");
Printf ("---------- 0. Exit program --------- \ n ");
Printf ("select :");
Scanf ("% d", & n );
Switch (n)
{
Case 1:
{
A = rand () % 100 + 1;
B = rand () % 100 + 1;
Printf ("% d + % d = \ n", a, B );
Break;
}
Case 2:
{
C = rand () % 100 + 1;
D = rand () % 100 + 1;
Printf ("% d-% d = \ n", c, d );
Break;
}

Case 3:
{
E = rand () % 100 + 1;
F = rand () % 100 + 1;
Printf ("% d * % d = \ n", e, f );
Break;
}
Case 4:
{
G = rand () % 100 + 1;
H = rand () % 100 + 1;
Printf ("% d/% d = \ n", g, h );
Break;
}

}


}

 

Summary:

I used the classroom time to complete this small program. In addition to the time explained by the teacher and the time of class, there were 10 minutes left. This is an original blog post. Although its technical content is low, it is also a new way of learning, a new beginning, and difficulties are constantly found in the programming process, the final process of solving the difficulties is the most wonderful moment for our programmers.

 

Related Article

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.