function magnitude

Pages: 12
Write C++ program that calls a function magnitude which returns the number multiplied by 10 have the user enter an integer and then call the function

how would I go about that?

You write it? Your class has just had functions, hasn't it?

Isn't it quite clear what the magnitude should do? That is a separate subtask.

The main() looks simple too: get a number, call magnitude.
its all online and the teacher just shoves out powerpoints. not the best teacher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream> 
#include <string> 
using namespace std; 

int magnitudeValues(int &number1, int &number2) { 
char answer; 
cout << "Do you want to change your entered numbers? (Y/N): "; 
cin >> answer; 

 { 
cout << "Enter your first number: "; 
cin >> number1; 
cout << "Enter your second number: "; 
cin >> number2; 
cout << "Your new entered numbers are " << number1 << " and " << number2 << "." << endl << endl; 
} 
 
int result = number1 ;multiply; number2; 
return result; } 

int main() { 
int number1, number2;  
cout << "This will multiply two numbers and show an answer."<<endl;
cout << "Enter your first number: "; 
cin >> number1; 
cout << "Enter your second number: "; 
cin >> number2; 
cout << "\nYou entered " << number1 << " and " << number2 << endl; 
int result = magnitudeValues(number1, number2); 
cout << "The answer by subtracting " << number1 << " from " << number2 << 
" is " << result << endl; } 


thats what i think would work so far
Why does magnitudeValues reprompt for user input? The function should only do what its name indicates, nothing more. That said, your function will reprompt for new numbers regardless of what the user enters for their yes/no choice. You'll need a conditional statement to check what the character input was ('Y' or 'N').

Also, your return statement in the magnitudeValues function is... off.
1
2
int result = number1 ;multiply; number2; 
return result;


I'm not sure what you were taught about arithmetic operators, but they're all symbols. Give the below page a quick read thorugh if you're confused.

http://www.cplusplus.com/doc/tutorial/operators/
would that program accomplish this?

Write C++ program that calls a function magnitude which returns the number multiplied by 10 have the user enter an integer and then call the function

i am pressed for time as this is due in just 3 hours.
bump
im so confused on this.
this is all that is there so far

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;

int multiplyValue (int &number1, int &number2) {

{
	cout << "Enter your first number";
	cin >> number1;
	cout << "Enter your second number: ";
	cin >> number2;
	cout << "Your new entered numbers are " << number1 << "and" << number2 << "." << endl;
	
}
int result = number1*number2;
return result; }

int main() {
Ask a more specific question. I'm not going to write the assignment for you, but I will answer your questions. What, specifically, don't you get?
thats fine.

how do i get the numbers to multiply to produce my result. when i have it as

int result = number1*number2; it doesnt do squat to multiply that for me?

i have my magnitude function at the top and i know i need a second half of the program. but then again maybe i dont. i just need it to times the number by 10
but am i in the right direction so far?
What do you mean by "times the number by 10"? You have two numbers that you're multiplying together, neither of them are guaranteed to be ten. Describe what you're trying to do and post your entire program. Comment the code and explain to me the purpose of each part.
this is what i was assigned. Write C++ program that calls a function magnitude which returns the number multiplied by 10 have the user enter an integer and then call the function for a final. i dont have any more C++ classes to take after this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;

int multiplyValue (int &number1, int &number2) {

{
	cout << "Enter your first number";
	cin >> number1;
	cout << "Enter your second number: ";
	cin >> number2;
	cout << "Your new entered numbers are " << number1 << "and" << number2 << "." << endl;
	
}


int main() 
{

its due by midnight. my book isnt much help at all
It looks like it wants you to get one integer from the user and use a function to multiply that integer by 10. What does your main function look like?
1
2
3
4
5
6
7
8
9
10
int number1, number2;  
cout << "This will multiply two numbers and show an answer."<<endl;
cout << "Enter your first number: "; 
cin >> number1; 
cout << "Enter your second number: "; 
cin >> number2; 
cout << "\nYou entered " << number1 << " and " << number2 << endl; 
int result = multiplyValues(number1, number2); 
cout << "The answer by multiplying " << number1 << " from " << number2 << 
" is " << result << endl; } 


its very sloppy because its also from a subtraction one.
Alright, your main function looks fine, provided that you do in fact want to take two numbers as input and output their multiplication. The multiplyValues should just take both numbers in the argument list and return n1*n2.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;

int multiplyValue (int &number1, int &number2) {

{
	cout << "Enter your first number";
	cin >> number1;
	cout << "Your entered numbers is " << number1 << endl;
	
}


int main() 
{
	
int number1, number2;  
cout << "This will multiply the number by 10 and show an answer."<<endl;
cout << "Enter your number: "; 
cin >> number1; 
cout << "\nYou entered " << number1 << " and " << number2 << endl; 
int result = multiplyValues(number1, number2); 
cout << "The answer by multiplying " << number1 << " from " << number2 << 
" is " << result << endl; } 


so what I would assume I want to do is take that users input interger and multiply that by 10 with the function but heres what the program does not like

int multiplyValue (int &number1, int &number2) {

so what can i adjust to make this work out?
Are you multiplying two user supplied numbers or taking one number from the user and multiplying it by 10? You're code takes two numbers but you keep saying that you want to multiply one number by 10.
i just want one number from the user and multiply it by 10 then to call that function. it seems like a disorganized assignment from the teacher.
Pages: 12