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!
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!
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;
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.