Software Engineering Second Job

Source: Internet
Author: User

Topic:
Please write a "software" that can automatically generate primary arithmetic topics.
Allow the program to accept the user to enter the answer, and determine the right and wrong.
Finally, the total number of pairs/errors is given.

    • Demand analysis
    1. can automatically generate add, subtract, multiply, divide arithmetic, and display in the console.
    2. The answers shown in the console are displayed and judged correctly or wrongly.
    3. Can count the total number of things to do and do wrong questions.
    • Design ideas
    1. After pressing any key, the input "1" for the addition operation, the input "2" for the subtraction operation, the input "3" for multiplication, the input "4" for the division operation;
    2. When the arbitrary choice of an operation will appear a corresponding topic, if the answer is not correct, will show "No,you is wrong!", if the answer is correct, will show "Yes,good job!" ;
    3. After completing a topic, enter "1" to continue to do the selected operation, enter "2" for the re-select operation, enter "3" then exit the operation;
    4. If you enter "2" in step 2nd, start the first step and enter 3 to exit the system if you do not have the problem, and count the total number of pairs/errors.
    • Code implementation

#include"stdio.h"#include"windows.h"intright=0, wrong=0;voidAdd () {intA,b,c; A=rand ()% -; b=rand ()% -; printf ("please answer:%d+%d=", A, b); scanf ("%d",&c); if(a+b!=c) {printf ("No,you is wrong!\n"); Wrong++; }    Else{printf ("Yes,good job!\n"); Right++;} }voidMinu () {intA,b,c; A=rand ()% -; b=rand ()% -; printf ("please answer:%d-%d=", A, b); scanf ("%d",&c); if(a-b!=c) {printf ("No,you is wrong!\n"); Wrong++; }    Else{printf ("Yes,good job!\n"); Right++; }}voidMul () {intA,b,c; A=rand ()% -; b=rand ()% -; printf ("please answer:%d*%d=", A, b); scanf ("%d",&c); if(a*b!=c) {printf ("No,you is wrong!\n"); Wrong++; }    Else{printf ("Yes,good job!\n"); Right++; } }voiddi () {intA,b,c; A=rand ()% -; b=rand ()% -; printf ("please answer:%d/%d=", A, b); scanf ("%d",&c); if(a/b!=c) {printf ("No,you is wrong!\n"); Wrong++; }    Else{printf ("Yes,good job!\n"); Right++; } }voidMain () {intchoise,con=0; printf ("\n\n\t\t Welcome to my C language four op \ n"); System ("Pause"); System ("CLS");  while(1) {printf ("\n\n\t\t Please select: \ n Plus (input 1) \ n minus (input 2) \ n (input 3) \ n (input 4) \ N"); if(con==0) scanf ("%d",&choise); Switch(choise) { Case 1: Add (); Break;  Case 2: Minu (); Break;  Case 3: Mul (); Break;  Case 4:d I (); Break; } printf ("Would you like to continue with this operation or do you want to re-select another operation or exit the program? \ n Continue (enter 1), re-select operation (enter 2), exit (enter 3)"); scanf ("%d",&con); if(con==1) con=1; if(con==2) con=0; if(con==3) Break; } printf ("you always do%d questions, correct%d of the Tao, error%d! \ n", right+Wrong,right,wrong); System ("Pause");} 

    • Effect

    • Analysis and summary
    1. PSP Time-consuming calculation

    1. Summary

First of all, because of the limited power, so the software has a lot of problems, when doing division operations do not come out.

Secondly, I think that for every thing, whether you like it or not, you have to have a good attitude when you do it, even if the result is not perfect, but at least there will be a result, if you do not do, even the result will not have.

Software Engineering Second Job

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.