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 & ... (4506)
- General Knowledge (1365)
- Sports (1262)
- Career and Education (1248)
- troubleshooting (987)
- Travel & Places (872)
- Current affair (759)
- Technology (474)
- Innovation, Discover... (356)
- USA History (343)
- Bollywood & Celebrit... (334)
- Airlines & Air Trave... (311)
- indian Polity and Co... (307)
- Richest and Most Pow... (300)
- social networking (294)
- Gadgets (257)
- Books & Novels (256)
- Freedom Fighter (228)
- Railways & Construct... (212)
- Cities (203)
- more..

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