Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Invlude all the steps and explanation please. Read and understand the sample batch files posted here. Copy them as save it in your PC as

Invlude all the steps and explanation please.
Read and understand the sample batch files posted here.
Copy them as save it in your PC as files with any name but with a .bat extension. Then run them in windows command prompt with just the name of the file. The power program asks for input of a number and a power (also a number), calculates and outputs the power of the number.
Write a batch program to accept a number as input from the user and calculate the factorial of a number. You must continue to accept input as long as the user enters option(y/n) as 'y' for an input. If the user types 'n' then you can end the program. (You can follow similar approach used in the power program)
Batch File 1:
@echo off
echo "This is addition of two numbers"
set /p a="num1"
set /p b="num2"
set /a s=a + b
echo sum =%s%
pause
Batch file 2:
@echo off
echo "This is finding the power of a number"
:loop
set /p a="num1"
set /p pow="power "
if %pow% LSS 0 goto step1
if %pow%==0 goto step2
set /a result=1
set /a power=0
:loop1
set /a result=%result%*%a%
set /a power=%power%+1
if %power% GEQ %pow% goto step3
goto loop1
:step3
echo "power %pow% of the number %a% is %result%
goto step4
:step2
echo "power %pow% of the number %a% is 1"
goto step4
:step1
echo "invalid entry"
:step4
echo "do you want to enter another number ?"
set /p option="y/n "
if %option%== y goto loop
pause

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What are some important criteria for Internet domain naming?

Answered: 1 week ago