Solved

Guys help please!!!

Posted on 2016-09-07
4
34 Views
Last Modified: 2016-11-12
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 :)
0
Comment
Question by:clinton Pitas
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
oBdA earned 500 total points (awarded by participants)
Comment Utility
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).
1
 

Author Comment

by:clinton Pitas
Comment Utility
Thank you oBdA,,,
Im very grateful to you and also gave me an advice...
hope to ask you again sometimes... :)
0
 
LVL 82

Expert Comment

by:oBdA
Comment Utility
Question answered.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now