#include <iostream>
usingnamespace std;
char wait4User;
void duplicate(int& a, int& b, int& c)
{
a = a * 2;
b = b * 2;
c = c * 2;
cout << "x=" << a << ", y=" << b << ", z=" << c;
}
int main ()
{
duplicate();
cin >> wait4User;
return 0;
}
My error is:
In function 'int main()': too few arguments to function 'void duplicate(int&, int&, int&)' at this point in file.
I'm really not sure what I am doing wrong. All I am trying to do is double all three of my ints and make it say x=(amount of a doubled), y=(amount of b doubled) etc.
And what is their value before you double it, in your opinion? Notice something's missing here?
The function takes three parameters, but you don't pass any when calling the function.
Oh... Wow...
How can I make it work though? I know i need the initial values inside of the void, but the rest of it I don't know now. Sorry about so many questions. I started taking a C++ class at my school, but its a distant learning class and the instructor rarely replies back to messages.
#include <iostream>
usingnamespace std;
char wait4User;
void duplicate(int& a, int& b, int& c)
{
a *= 2;
b *= 2;
c *= 2;
}
int main ()
{
int x = 4, y = 9, z = 14;
duplicate(a, b, c);
cout << "x=" << x << ", y=" << y << ", z=" << z;
cin >> wait4User;
return 0;
}
Edit: Changed the code a bit, made it so x actually equaled x instead of a..
It works completely now though with the changes I made and what I put into my last post.
x, y and z are supposed to be duplicates of a, b, and c respectively.