Arithmetic problems in the second grade of primary school

Source: Internet
Author: User

I. Topic requirements

Produce 300 primary school second grade of arithmetic mathematics problem, subtraction cannot appear negative numbers, division to divide evenly.

Two. Writing process

Write a math problem that produces 30 arithmetic of primary school sophomore, with Rand () generating random numbers, and random symbols, in the division operation in the case of the divisor is not zero by using a set of random numbers to generate dividend and divisor is the divisor of the integer multiples, so as to ensure division, subtraction to determine the size of two random numbers, The result of the output is a large number minus a decimal. Then use the For loop 30 times to output a 30-way problem.

Three. Program operation

Four. Program code

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void Main ()
{
int A, B, C, D, E, I, J;
Srand (Time (NULL));
printf ("Arithmetic in the second year of primary school \ n");
for (i = 0; i <; i++)
{
A = rand ()% 100;
b = rand ()% 100;
c = rand ()% 4;
Switch (c)
{
Case 0:
printf ("%d+%d=\n", A, b);
Break
Case 1:
if (a < b)
{
printf ("%d-%d=\n", B, a);
}
Else
printf ("%d-%d=\n", A, b);
Break
Case 2:
printf ("%d*%d=\n", A, b);
Break
Case 3:
{
d = rand ()% 20;
if (d! = 0)
e = rand ()% 4;
Switch (e)
{
Case 0:
printf ("0÷%d=\n", D);
Break
Case 1:
printf ("%d÷%d=\n", D, D);
Break
Case 2:
j = 2 * D;
printf ("%d÷%d=\n", J, D);
Break
Case 3:
j = 3 * D;
printf ("%d÷%d=\n", J, D);
Break
}
Break
}
}
}
System ("pause");
}

Arithmetic problems in the second grade of 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.