0

Someone please help me with my school assignment

QUESTION: Write a program that accepts data in one dimensional arrays Addition, multiplication, division and subtraction. Any two arrays that you have created. -Array should be minimum of 3. **in C++

16th Nov 2017, 10:49 AM
Jamal Jillo
Jamal Jillo - avatar
53 Answers
+ 3
You should be able to figure out some of it. Do so and post it to get suggestions on finishing it.
16th Nov 2017, 11:42 AM
John Wells
John Wells - avatar
+ 3
You should do your homework yourself and not ask people to do it for you. If you have trouble doing it, then post your code and then we will help you. 😉
16th Nov 2017, 12:32 PM
blackcat1111
blackcat1111 - avatar
+ 2
First, before declaring values, you should read first_number and second_number. You're array currently has garage in it because they haven't been read as yet. Second, you are meant to have two arrays based on your initial question so you need to do it twice. Third, you need to use loops to do each operation on the two arrays either storing into a third array to be printed later or directly print it as you go.
16th Nov 2017, 3:45 PM
John Wells
John Wells - avatar
16th Nov 2017, 4:26 PM
Jamal Jillo
Jamal Jillo - avatar
16th Nov 2017, 4:54 PM
John Wells
John Wells - avatar
+ 2
Oh thanks i see where i went wrong i have to input my numbers first before put them in the array memory
16th Nov 2017, 5:01 PM
Jamal Jillo
Jamal Jillo - avatar
+ 1
Ok this is what I've been able to do , the only problem is ,I don't want it display each calculation if i could be able to call the specific calculation for example if i wanted to perform addition then the program would show the result of addition only and not the rest😀thank you #include <iostream> using namespace std; int main() { int first_number; int second_number; int values[]={first_number,second_number}; cin>>first_number; cin>>second_number; int sum; sum = first_number+second_number; cout<<sum<<endl; int subtraction; subtraction=first_number-second_number; cout<<subtraction<<endl; int multiply; multiply=first_number*second_number; cout<<multiply<<endl; int division; division=first_number/second_number; cout<<division<<endl; return 0; }
16th Nov 2017, 3:12 PM
Jamal Jillo
Jamal Jillo - avatar
+ 1
Start out like int first_number; int second_number; char op; cin>>first_number; cin>>second_number; int values1[]={first_number,second_number}; cin>>first_number; cin>>second_number; int values2[]={first_number,second_number}; int values3[2]; cin>>op; switch (op){ case '+':
16th Nov 2017, 10:53 PM
John Wells
John Wells - avatar
+ 1
I know the question requires a second array but I don't know what to do with them once i read them? What will be the use of values2 and values3? Heres the modified code https://code.sololearn.com/cLCoCjtE5U9F/?ref=app
17th Nov 2017, 8:00 AM
Jamal Jillo
Jamal Jillo - avatar
+ 1
You need to add like: values3[i]=values1[i]+values2[i]; for i = 0 and 1.
17th Nov 2017, 12:32 PM
John Wells
John Wells - avatar
+ 1
values1[] = {3, 5}; values2[] = {4, 6}; values3[] = {3+4, 5+6} = {7, 11}
17th Nov 2017, 3:07 PM
John Wells
John Wells - avatar
+ 1
https://code.sololearn.com/cy2yEKZwmM2d/?ref=app Here is what I have to add to this discussion. I only did the addition.
17th Nov 2017, 3:55 PM
Zeke Williams
Zeke Williams - avatar
0
Please take your code and link it here. I am willing to walk you through the coding process, but we both need access to the same code.
16th Nov 2017, 3:59 PM
John Wells
John Wells - avatar
0
Thank you,,how do i link the code here?
16th Nov 2017, 4:03 PM
Jamal Jillo
Jamal Jillo - avatar
0
I'm using the app
16th Nov 2017, 4:08 PM
Jamal Jillo
Jamal Jillo - avatar
0
Under the line you type in, there is a plus sign and insert. Tap that. Select code. Select my Codes. Tap on your program and a web link will be added to your post.
16th Nov 2017, 4:16 PM
John Wells
John Wells - avatar
0
Thats it
16th Nov 2017, 4:26 PM
Jamal Jillo
Jamal Jillo - avatar
0
What do you mean when you say my array has a garage in it?
16th Nov 2017, 4:35 PM
Jamal Jillo
Jamal Jillo - avatar
0
You didn't put anything in your numbers as yet so you might get zero or whatever value was in that memory location left behind by something else. That's garbage as it is some random value. That is one of the worst bugs to find in a program because it causes random behavior.
16th Nov 2017, 4:39 PM
John Wells
John Wells - avatar
0
The program needs to accept numbers as you run it and execute them,,so I'm not really getting what you're saying
16th Nov 2017, 4:44 PM
Jamal Jillo
Jamal Jillo - avatar