How to perform calculation ON CMD?

0 votes

How to perform calculation ON CMD?

0 votes

**In general, we use a calculator or any app for doing any calculation on windows, but other than that, we can also use DOS based calculator i.e Command Prompt that works through a set of commands.** Calculating arithmetic expressions on command line is more easy and expressive than other methods. Because command line comes very handy, when solving some complex logic.

The built-in DOS Shell has comprises of a mini calculator that can calculate simple arithmetic expressions on 32 bit signed integer.

The **“SET”** with /a switch DOS command is used to perform calculation on command prompt.

To know more on this command **type set /?** on the command prompt.

**
Below are some of the general expressions: **

C:\>set /a 3+3 will output 6

C:\>set /a 3*3 will output 9

C:\>set /a 8/4 will output 2

C:\>set /a 2+2 will output 4

C:\>set /a 5*(2/2)+10 will output 15

C:\>set /a (5*2)/2+10 will output 15

C:\>set /a “15>>2” will output 3

**
It also support other types of operators. Always remember to enclose the expression string in quotes when using logical or modulus operator. **

The following table lists the operators supported for /a in descending order of precedence.

**Note: It overflow values for decimal integer. It removes the decimal point value and round of the integer. i.e 13/2 will result 6 instead of 6.5.
**

- All categories
- History, Politics & ... (4048)
- Career and Education (1248)
- Sports (1244)
- General Knowledge (1231)
- Travel & Places (868)
- Current affair (702)
- Technology (453)
- Innovation, Discover... (356)
- Bollywood & Celebrit... (332)
- Airlines & Air Trave... (309)
- troubleshooting (304)
- indian Polity and Co... (303)
- Richest and Most Pow... (300)
- social networking (294)
- Books & Novels (234)
- Freedom Fighter (228)
- USA History (212)
- Railways & Construct... (211)
- Cities (203)
- Q&A categories (188)
- more..

## Please log in or register to add a comment.