My objective is to supply a number initially and obtain a result that adds 10 to it using 2 separate functions:
1st function that supply the number;
2nd function to add the number to 10;
This is what i have written;
but cant think of how to put the supplied number into 2nd function..
#include<stdio.h>
int init_int(int alpha);
void modify_int(int alpha);
int main(void)
{
int b;
int alpha;
int InitialNum;
InitialNum = init_int(b);
printf("The number that you have entered is: %d\n", InitialNum);
modify_int(b);
return(0);
}
int init_int(int alpha)
{
int InitialNum;
printf("Please supply an integer:\n");
scanf("%d", &InitialNum);
return InitialNum;
}
void modify_int(int)
{
int InitialNum;
InitialNum += 10;
printf ("The final answer is: %d\n", InitialNum);
return;
}
1. Replace void modify_int(int) with void modify_int(int alpha).
2. What does init_int() receives an int for?
3. What do you use b for in main()?
4. What do you use InitianNum for in modify_int()? Replace all of its instances in that function with alpha.
5. What do you use alpha for in main()?
6. returns at the end of functions returning void are redundant and you don't need to use them.