473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C++ while to recognize when ive multiplied using addition

Hi guys.
I am currently working as a HTMLcoder for a company here in Sweden and I thought it would be great to learn some software development too so I bought myself a book reg. c++.
However there is something I've not been able to solve yet.
It's one of the questions in the book and this is how it should be done.

I will input two numbers (let's say 3 and 5) and that's no problem.
Then I should use addition using a (while?) loop to make it 3+3+3 etc. until it reaches 15 and then it should print $sum, however this has me wondering.
If I define x/y integers then should I add a sum integer too?
I believe that I in some way need to make the condition while (sum=x*y) .... if sum=xy cout sum?
But I cant get this to work with the integers x,y,sum where am I thinking wrong?
What approach should I take to solve it?

Thanks and sorry if anything's unclear just ask.
Oct 9 '08 #1
1 1200
Banfa
9,065 Expert Mod 8TB
Are you familiar with the concept of multiplication as repeated addition. For a sum y = a x b you can add b to itself a times or add a to itself b times.

Coding this you need to use a loop (personally I would use for) that for b iterations adds a onto the sum.
Oct 9 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: das dsf | last post by:
Hi there! I have both PHP 4.0( RPM) installed and MySQL 4.0.20 installed with the mysqld daemon up and running. But when I look at the output of phpinfo() , I do not see it there, which is...
10
by: Wes Johnson | last post by:
I've encountered a problem where I am changing a particular c source document and then running the associated make command in the console. If I then run that program, it is as though the update has...
29
by: keredil | last post by:
Hi, Will the memory allocated by malloc get released when program exits? I guess it will since when the program exits, the OS will free all the memory (global, stack, heap) used by this...
8
by: J. D. Leach | last post by:
I am not sure whether this would be considered off topic or not, but here goes.....don't flame me too bad. Running GNU GCC 4.0.1 and GDB 6.3. Was checking my compiler and debugger output prior...
3
by: naveen.sabapathy | last post by:
Hi, I am trying to use virtual serial ports to develop/test my serial communication program. Running in to trouble... I am using com0com to create the virtual ports. The virtual ports seem to...
5
by: CyberSoftHari | last post by:
How to Recognize key pressed when the application is in system tray? I am using a context menu with some hot keys (like Alt+Ctrl+Delete) once I press the key my appropriate command should...
78
by: Jeremy J Starcher | last post by:
(Request for Discussion) I've put together a guide that I hope will help novice coders avoid the same hair pulling that I went through. I'm open for comments about it. Have I missed the...
7
by: MLH | last post by:
If I'm using the following in a procedure... DoCmd.GoToRecord acDataForm, "FormName", acNext, 4 .... how can I recognize the EOF condition? Using GoToRecord, I find myself lost when trying to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.