-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.bat
More file actions
56 lines (47 loc) · 1.13 KB
/
code.bat
File metadata and controls
56 lines (47 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@echo off
setlocal enabledelayedexpansion
echo Welcome to the Basic Math Tutorial!
echo.
echo Choose an operation:
echo 1. Addition
echo 2. Subtraction
echo 3. Multiplication
echo 4. Division
echo.
set /p choice="Enter the number corresponding to the operation: "
if "%choice%"=="1" goto addition
if "%choice%"=="2" goto subtraction
if "%choice%"=="3" goto multiplication
if "%choice%"=="4" goto division
echo Invalid choice. Please select a number between 1 and 4.
goto end
:addition
set /p a="Enter the first number: "
set /p b="Enter the second number: "
set /a result=%a% + %b%
echo %a% + %b% = %result%
goto end
:subtraction
set /p a="Enter the first number: "
set /p b="Enter the second number: "
set /a result=%a% - %b%
echo %a% - %b% = %result%
goto end
:multiplication
set /p a="Enter the first number: "
set /p b="Enter the second number: "
set /a result=%a% * %b%
echo %a% * %b% = %result%
goto end
:division
set /p a="Enter the first number: "
set /p b="Enter the second number: "
if %b%==0 (
echo Error: Division by zero is not allowed.
) else (
set /a result=%a% / %b%
echo %a% / %b% = %result%
)
goto end
:end
pause