How to multiply unlimited number according to our desire in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to multiply unlimited number according to our desire in c++

Hello friends this is my code. i am trying to make calculator and i want to make function for multiplication where i can multiply unlimited numbers. I am unable to understand. please solve my problem. Here is the code #include<iostream> using namespace std; int main(int argc, char const *argv[]) { int number, limit; double mult = 0; cout<<"How many numbers do you want to multiply? "<<endl; cin>>limit; for (int i = 0 ; i < limit ; i++) { cout<<"Enter number :"<<endl; cin>>number; mult=mult*number; } cout<<"Multiplication is "<<mult<<endl; return 0; }

5th Jul 2022, 5:50 PM
Avinash
Avinash - avatar
3 Answers
+ 3
Initially you are taking mul=0 so anything*0 =0 Take double mult=1 ; everything works fine....try it now..
5th Jul 2022, 6:11 PM
Jayakrishna 🇮🇳
+ 1
5th Jul 2022, 6:15 PM
Avinash
Avinash - avatar
+ 1
You're welcome..
5th Jul 2022, 6:15 PM
Jayakrishna 🇮🇳