+ 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; }
3 Réponses
+ 3
Initially you are taking mul=0 so anything*0 =0
Take double mult=1 ; everything works fine....try it now..
+ 1
Thank you Jayakrishna🇮🇳
+ 1
You're welcome..