Hi! I have an assignment. A C++ program. But sad to say I dont know how.

-Write a program that multiplies two numbers withou using (*symbol). (Use for loops)

Please help me!

satheeshsoft commented: /**********************************************/ /* multiplying two numbers without * but loops*/ int num = 7 /*2*/; int num1 = 15/*3*/; //6, if +0

Can you think of a method that uses addition?

Post the code which you tried.

As exponentiation is repeated multiplication, so is multiplication repeated addition. In programming, when you have to do repeated things, you can use a loop structure(e.g. a for loop)

#include<iostream>
using namespace std;
int main()
{
int n1,n2,holder=0;
cin>>n1>>n2;
for (int i=0;i<n2;i++)
{
holder=holder+n1;

}
cout<<holder<<endl;
}
commented: int num3 = 0; for(int i = 0; i < num1; i++) { num3 += num; } int numanswer = num3; +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.