Code:
#include <stdio.h>
#include <stdlib.h>
void half(int i); //// need prototype of function
int main() {
int i;
printf("Please enter an integer...\n");
scanf(" %d", &i);
// Now call the half function, passing the value of i
half(i); //// need semicolon here
// Shows that the function did not alter i's value
printf("In main(), i is still %d.\n", i);
return 0;
}
//// If you want your function to have no return value then
//// you need to explicitly make it void.
void half(int i) { // Receives the value of i
i = i / 2; //// presumably you mean i / 2 here
printf("Your value halved is %d.\n", i);
return; // Returns to main //// unnecessary, returns at ending brace anyway
}