5* for first person who helps me fix. Sorry about messy code and comments my compiler doesn't handle copy well.
#include %26lt;stdio.h%26gt;
#include %26lt;stdlib.h%26gt;
/*Asks the user their age, reads input, and returns value*/
void readAge(int *age);
/* Tells the age back*/
void writeAge(int age);
void doubleAge(int *age);
void halveAge (int *age);
/*Sets up the main goal of the function by asking for age and returning
the value along with other statements*/
int main(void) {
/* Interger variable for age. */
int age;
readAge(%26amp;age);
writeAge(age);
doubleAge(%26amp;age);
halveAge(%26amp;age);
/* Tells computer everything is a-ok*/
return EXIT_SUCCESS;
}
void readAge(int *age )
{
printf("How old are you?");
scanf("%d", age);
}
void doubleAge(int *age)
{
printf("Double that time and... \n", age);
writeAge( *age = age * 2);
printf("Wow that's old! \n", age);
}
void halveAge(int *age)
{
printf("Now if I cut your age in half... \n", age);
writeAge(age / 2);
printf("Haha you're almost a kid again! \n", age);
}
/* Repeating statement after every line*/
void writeAge(int age)
{
printf("You are %d!\n\n", age);
}|||writeAge( *age = age * 2);
You are passing the result of an assignment statement to writeAge?
do you mean:
*age *= 2;
writeAge(*age);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment