Guys help please!!!

clinton Pitas
clinton Pitas used Ask the Experts™
on
I'm having trouble with my %ctr% dont know if its the right code for this
what I'm looking is if you multiply 7 to 7 the output should come to this:
1 x 7=7
2 x 7=14
3 x 7=21
4 x 7=28
5 x 7=35
6 x 7=42
7 x 7=49

Open in new window

this is my code:
@echo off

:start

set /p i=insert a number:
set /p a=multiplied times:
goto multi

:multi
set /a ctr=%ctr%+1 -->problem
set /a pro=%i%*%a%
echo %i% x %a%=%pro%
pause

goto start

Open in new window



thanks Guys :)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Use a count loop (and do yourself a favor and use self-explaining variable names instead of letters).
@echo off
setlocal enabledelayedexpansion
:start
set Number=
set /p Number=insert a number, or nothing to exit: 
if "%Number%"=="" goto :eof
set /p Times=multiplied times: 

for /L %%i in (1, 1, %Times%) do (
	set /a Product = %%i * Number
	echo %%i x %Number% = !Product!
)
pause
goto start

Open in new window


And please post code in "Style Code" tags (see the tool bar above the Comment box).

Author

Commented:
Thank you oBdA,,,
Im very grateful to you and also gave me an advice...
hope to ask you again sometimes... :)
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
Question answered.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial