|
CS256 - Fundamentals of Structured Programming
| Displaying exercises/e2/solution/func.c
// Add the missing include we need to do I/O functions with:
#include <stdio.h>
/**
* Create the missing sum function that takes 4 integer values and returns
* the sum of those 4 values as it's return value:
*/
int sum(int a, int b, int c, int d)
{
return a + b + c + d;
}
int main(void)
{
// Define the missing integer variable n:
int n;
printf("Enter an integer: ");
scanf("%d", &n);
printf("%d + %d + %d + %d = %d\n",
n, n+1, n+2, n+3, sum(n, n+1, n+2, n+3));
// Add the return value for main:
return 0;
}
|