18 lines
325 B
C
18 lines
325 B
C
// Averages three numbers using an array and a loop
|
|
|
|
#include <cs50.h>
|
|
#include <stdio.h>
|
|
|
|
int main(void)
|
|
{
|
|
// Get scores
|
|
int scores[3];
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
scores[i] = get_int("Score: ");
|
|
}
|
|
|
|
// Print average
|
|
printf("Average: %f\n", (scores[0] + scores[1] + scores[2]) / 3.0);
|
|
}
|