Sure! Here's a C program that accepts an integer value from the keyboard and then passes it to two different functions for squaring and cubing:
```c
#include <stdio.h>
int square(int num) {
return num * num;
}
int cube(int num) {
return num * num * num;
}
int modify(int num) {
if (num == 0) {
return 2;
}
return num;
}
int main() {
int num, modified;
printf("Enter an integer value: ");
scanf("%d", &num);
modified = modify(num);
int squared = square(modified);
int cubed = cube(modified);
printf("Squared: %d\n", squared);
printf("Cubed: %d\n", cubed);
return 0;
}
```
Explanation:
1. We start by including the necessary header file `stdio.h` for input/output operations.
2. We define three functions: `square`, `cube`, and `modify`, each taking an integer as input and returning an integer.
3. The `square` function multiplies the input number by itself and returns the result.
4. The `cube` function multiplies the input number by itself twice (cubes it) and returns the result.
5. The `modify` function checks if the input number is 0. If it is, it returns 2; otherwise, it returns the input number itself.
6. In the `main` function, we declare the variables `num` (to store the input number) and `modified` (to store the modified value).
7. We prompt the user to enter an integer value and store it in `num` using `scanf`.
8. We call the `modify` function with `num` to get the modified value, and store it in `modified`.
9. We call the `square` function with `modified` to get the squared value and store it in `squared`.
10. We call the `cube` function with `modified` to get the cubed value and store it in `cubed`.
11. Finally, we display the squared and cubed values using `printf`.
Note: The program assumes that the user will enter a valid integer input. Error handling for incorrect input is not included in this example.