write a programme that reads two integers and multiply themeach of them 50 digit
ID: 3613186 • Letter: W
Question
write a programme that reads two integers and multiply themeach of them 50 digits long.(using array) i don't know what's wrong with mycode,, can anybody fix it for me please??? #include <iostream>using namespace std;int main(){int n1[50], n2[50], r[100], c[51];int i,s1,s2,j,sum;cout<<"Enter first long integer";i=0;while (i<50){do{cin >> n1[i];}while ((n1[i] < 0) || (n1[i] > 9));i++;}s1 = i-1;cout<<"Enter second long integer";i=0;while (i<50){do{cin >> n2[i];}while ((n2[i] < 0) || (n2[i] > 9));i++;}s2 = i-1;for (i=0; i<51; i++)c[i]=0;i=0;sum=0;while (i<s2){for (j=0; j<s1; j++)sum = sum + n1[j]*n2[i];x = n1[j]*n2[i];system ("PAUSE");return 0;} write a programme that reads two integers and multiply themeach of them 50 digits long.(using array) i don't know what's wrong with mycode,, can anybody fix it for me please??? can anybody fix it for me please???
#include <iostream>using namespace std;int main(){int n1[50], n2[50], r[100], c[51];int i,s1,s2,j,sum;cout<<"Enter first long integer";i=0;while (i<50){do{cin >> n1[i];}while ((n1[i] < 0) || (n1[i] > 9));i++;}s1 = i-1;cout<<"Enter second long integer";i=0;while (i<50){do{cin >> n2[i];}while ((n2[i] < 0) || (n2[i] > 9));i++;}s2 = i-1;for (i=0; i<51; i++)c[i]=0;i=0;sum=0;while (i<s2){for (j=0; j<s1; j++)sum = sum + n1[j]*n2[i];x = n1[j]*n2[i];system ("PAUSE");return 0;} Explanation / Answer
I am having a hard time understanding the instructions for theassignment. I understand the reading two numbers but what is this 50digits long stuff. does that mean that each number entered has tobe 50 digits long? Or there has to be 50 numbers? I would think about replacing the while do structure why notjust use: cout<<"enter some digits"; while(cin>>n1[i]){ n++} without understanding the assignment better I can not helpfurther.why are you using the logical or "||" to check for values less than0 or greater than 9?
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.