# include <iostream>
# include <cmath>
usingnamespace std;
void giveWeeks (int & days );
void giveDays (int & days);
int main ()
{
int inNum;
cout << "Please enter number of days:";
cin >> inNum;;
cout << inNum <<" days have: \n";
giveWeeks(inNum);
cout << inNum <<" weeks \n";
giveDays (inNum);
cout << inNum << " days remaining ";
system ("pause");
return 0;
}
void giveWeeks (int & days)
{
days = days / 7;
}
void giveDays (int & days)
{
days = days % 7;
}
AND WHAT THE HELL ???? To initialize a function you cant write just void function!!! ill give you an eg.
1 2 3 4 5 6 7 8
// THIS IS A FUNCTION
void DisplayTheArray(double anArray[], int Start, int End)
{
for (int i=Start; i<=End; ++i)
{
cout<<"The "<<i+1<<"th element of the array is: "<<anArray[i]<<"\n";
}
}
This function can be used in main program to display the array elements by simply writting : DisplayTheArray(anArray[z]) //where z should be a number between Start and End
also, i think you need a more detailed example>>
something like this :
void giveWeeks (int & days)
{
days = days / 7;
}
void giveDays (int & days)
{
days = days % 7;
}
but he/she still has mistakes !
PS: THIS FORUM IS FOR C++ NOT FOR ENGLISH (dont tell me is not initialise as i didnt ask you !)
PS2: IF YOU STILL TOLD ME ABOUT MY ENGLISH , NEVER USE Also, also
I know I shouldn't feed the trolls, but I can't resist.
c = sqrt(a);
Fixed that for ya. EDIT: on farther inspection, sqrt only takes one argument.
I don't have one eye. Do you have more than one caps lock key?
(NOTE: The comment which prompted this response has since been edited out.)
I don't work for a big company, but I do work in the engineering department for a local company writing code for embedded systems. So, do you work for Google/IBM/etc.?
(NOTE: This question was also edited out.)
EDIT:
I wasn't criticising your English, I was criticising your use of terminology (which is quite relevant to a C++ forum)... as well as making a point about how irritating pedants are. ;)
You're assigning a value to a variable through user input, and then over-writing that value with your first function. This is what's causing the unexpected behaviour when you call the second function.
(see my first comment about functions returning values)