Fundamentals of C + + programming 108-arithmetic operators

Source: Internet
Author: User
Tags arithmetic arithmetic operators

1 //08-arithmetic operator. CPP: The entry point that defines the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7 using namespacestd;8 9 intMain ()Ten { One     //+-*/% subtraction (die) A     intA; -cout <<"Please enter the first number:"<<Endl; -Cin >> A;//cin is waiting for user input and the user does not enter the program to pause there. After the user enters, the user enters a value to a, and proceeds to the following code.  the  -     intb; -cout <<"Please enter a second number:"<<Endl; -CIN >>b; +  -     intRes1 = A +b; +     intRes2 = A-b; A     intRes3 = A *b; at     intRes4 = A/b;//The int type is divided, the result is the int type, and if it is not divisible, the part of the decimal point is omitted.  -  -cout << res1 <<"   "<< Res2 <<"   "<< Res3 <<"   "<< res4 <<Endl; -     //the operand of the subtraction is related to the variable type at both ends of the equals sign.  -  -     intRES5 = -%5; incout << res5 << Endl;//both ends of the modulo operation must be integers, and C + + does not support fractional redundancy.  -      to     //Operator Precedence: +     intRES6 =3+7*3;//first multiply and then add -     intRes7 =3+3;//The equals sign has the lowest priority, and the last Operation the     intRes8 = (3+7) *3;//The first operation is in parentheses.  *     intRES9 = the/7*3;//try not to write this, it is best to use parentheses to make the need to calculate first (42/7) $cout << res6 <<"   "<< res7<<"   "<< Res8 <<"   "<< RES9 <<Endl;Panax Notoginseng  -  the     intT; +CIN >>T; A     return 0; the}

Fundamentals of C + + programming 108-arithmetic operators

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.