
An Average Example
#include <stdio.h>
int main(void)
{
// Read the numbers.
printf("Enter: ");
int n1;
int n2, n3;
scanf("%d %d %d", &n1, &n2, &n3);
// Compute the sum and average.
double sum = n1 + n2 + n3;
printf("Mean %d %d %d is %f\n", n1, n2, n3, sum/3.0);
return 0;
}
Variable declaration.
Must follow {
Printf for output.
Scanf for input.
Use & before variables.
Conversions: %d, %f, %c, %x
Assignment.
The ability to declare where you like is new as of C99.
Originally: Only after {
Reading: Ch. 4; pp. 264-270