Hello I am new here and just thought it nice to introduce myself.
I have been messing around with C++ for quite some time, off and on. I pretty much know the basics, depending on what YOU think the basics are. I am writing this program for the fun of it and to learn more about this language. I am making very good progress but I have come across a little problem.
1.The program is built to get 2 different ages from different people.
2. Calculate the difference between the two people.
3. Calculate how old one person will be when the other is at a different age.
It will compile and it works except that the value that is returned from GetAge() is a lengthy number that I know is incorrect. I think I know why there is confusion in the program. When I call the function Diff() I think it is changing the value of int a or it just gets lost. I was thinking that I would have to use a getline(), but I don't know how that works and I am still researching how it works.Code:
# include <iostream.h>
int Diff(int a, int b)
cout << "In Diff(), received " << a << " and " << b << ".\n";
int GetAge(int a,int y)
cout << "In GetAge() , received " << y << " also received " << a << ".\n";
cout <<"I'm in main.\n";
int a, b, c, x, y, z, f;
cout <<"This function will hopefully calculate the age difference between\n";
cout <<"me and my nephew.\n";
cout <<"Enter your age.\n";
cout <<"Enter your newphews age.\n";
cout <<" \nCalling Difference()\n";
cout <<"Back in main.\n";
cout << "c was set to " << c << ".\n";
cout <<"Wasn't that fun?";
cout <<"Now lets try something a little more complex ok?\n";
cout <<"This time we will calculate how old your nephew will be when you are a certain age.\n";
cout <<"How old do you want to be?\n";
cout <<"The age difference between your actual age and the age you want to be is " <<x << ".\n";
If anyone can help I would be most appreciative. :) Thanx