A community for students.
Here's the question you clicked on:
 0 viewing
Jas11
 3 years ago
i'm getting errors in my program and need help
error C2109: subscript requires array or pointer type
error C2440: '=' : cannot convert from 'int' to 'int []'
error C2146: syntax error : missing ';' before identifier 'c'
Jas11
 3 years ago
i'm getting errors in my program and need help error C2109: subscript requires array or pointer type error C2440: '=' : cannot convert from 'int' to 'int []' error C2146: syntax error : missing ';' before identifier 'c'

This Question is Closed

Jas11
 3 years ago
Best ResponseYou've already chosen the best response.0this is my program the error is from the last function //harjasdeep Samra //This program will test three functions capable of reading, adding, and printing 100digit numbers. #include <iostream> #include<string> using namespace std; // Do not change these function prototypes: void readBig(int[]); void printBig(int[]); void addBig(int[], int[], int[]); // This constant should be 100 when the program is finished. const int MAX_DIGITS = 100; //There should be no changes made to the main program when you turn it in. int main() { // Declare the three numbers, the first, second and the sum: int num1[MAX_DIGITS], num2[MAX_DIGITS], sum[MAX_DIGITS]; bool done = false; char response; while (!done) { cout << "Please enter a number up to "<<MAX_DIGITS<< " digits: "; readBig(num1); cout << "Please enter a number up to "<<MAX_DIGITS<< " digits: "; readBig(num2); addBig(num1, num2, sum); printBig(num1); cout << "\n+\n"; printBig(num2); cout << "\n=\n"; printBig(sum); cout << "\n"; cout <<"test again?"; cin>>response; cin.ignore(900,'\n'); done = toupper(response)=='N'; } return 0; } //ReadBig will read a number as a string, //It then converts each element of the string to an integer and stores it in an integer array. //Finally, it reverses the elements of the array so that the ones digit is in element zero, //the tens digit is in element 1, the hundreds digit is in element 2, etc. void readBig(int x[]) { int length, i, oneLess, l; string number; getline(cin,number); length=number.length(); l=length1; oneLess=MAX_DIGITS1; for(i=0;i<MAX_DIGITS;i++) { x[i]=0; } for(i=0;i<=length1;i++) { x[i]=number.at(l)'0'; l; } } //PrintBig uses a while loop to skip leading zeros and then uses a for loop to print the number. void printBig(int a[]) { int count, i=0; bool x=true; count=MAX_DIGITS1; while(x) { if(a[count]!=0) x=false; //else if(count==MAX_DIGITS1) //x=false; else //i++; count; } for(i=count;i>=0;i) cout<<a[i]; } //AddBig adds the corresponding digits of the first two arrays and stores the answer in the third. //In a second loop, it performs the carry operation. void addBig(int a[], int b[], int c[]) { int i, temp, ones, carry; for(i=0;i<=MAX_DIGITS1;i++)//sets the int c[] to zero c[i]=0; for(i=0;i<=MAX_DIGITS1;i++) { c[i]=a[i]+b[i];//adds the arrays togther } for(i=0;i<=MAX_DIGITS1;i++) { ones=c[i]%10; carry=c[i]/10; c=carry[i]; c=ones + carry c[i+1]; } }
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.