I tried to make things as readable as possible:
Code:
#include <stdio.h>
int main( void )
{
// _1, _2, _3 = input numbers from the user
// We use these numbers to find the average of them
int _1, _2, _3;
// t = Total of all of the 3 input numbers added together
// a = Average of the input numbers
int t;
int a;
// Ask the user for the numbers seperated by a space
printf( "Enter all three numbers seperated by a space: " );
scanf( "%d %d %d", &_1, &_2, &_3 );
// Calculate the total
t = _1 + _2 + _3;
// Get the average: TOTAL / TOTAL_NUMBERS
a = t / 3;
// Output average
printf( "%d\n", a );
// Exit success
return 0;
}
Some example runs:
Code:
Shiva:/home/kleid/Programming/Laboratory# ./a.out
Enter all three numbers seperated by a space: 3 5 2
3
Enter all three numbers seperated by a space: 1 5 10
6
Enter all three numbers seperated by a space: 10 30 80
37