In today’s article, we are going to **write a c program to find the average of three** **number**

We will make this program in various ways. These are as follows:

- C Program to Find the Average of Three Numbers
**(Simple Way)** - C Program to Find the Average of Three Numbers
**using Function** - C Program to Find the Average of Three Numbers
**using Array**

Let’s understand all those methods one by one.

## C Program to Find the Average of Three Numbers

To find the average of three numbers, we will use the formula to find the average.

**Average of three number formula**

Average = Sum/Count

Here Sum will be obtained by adding three numbers and instead of Count, it will be 3 because here we are taking the average of 3 numbers, if we take the average of 5 numbers, then 5 will come in place of Count.

Now let’s actually start to program.

## C Program to Find the Average of Three Numbers (Simple Way)

### Algorithm

- Program Start
- Declaring Variables
- Input Three Numbers in Variables
- Calculating Average of Three Numbers (average = sum/count)
- Displaying the Average of Three Numbers
- Program End

**Program **

```
//C Program to Find the Average of Three Numbers (Simple Way)
#include<stdio.h>
void main()
{
int x, y, z; //Declaring Three Variables
float avg;
printf("Enter Three Numbers : \n");
scanf("%d %d %d",&x, &y, &z); //Input Numbers
avg=(x+y+z)/3.0; //Calculating Average of three numbers
printf("Average of Three Numebers is : %f", avg);
}
```

### Output

```
Enter Three Numbers :
10
2
38
Average of Three Numebers is : 16.666666
```

### Program Explanation

- In this program, we first declared three variables x, y, z.
- After that created a variable named avg with the help of float data type
- In this avg variable, we will store the average of the number three.
- After declaring the variables, we got input three numbers from the user and store those values in the x, y, z variables.
- After this, we Calculate the average of three numbers using the formula (average = sum/count) and stored its result in the avg variable.
- Finally, we printed the stored value in this avg variable on the screen with the help of printf() function.
- In this program, when we calculate the average of three numbers, we wrote 3.0 instead of 3, which means the same thing in maths.

## C Program to Find the Average of Three Numbers Using Function

To find the average of three numbers through a function, first you need to know about the function. You can read about the function from the link given below.

### Algorithm

- Program Start
- Declaring variables
- Input Numbers
- Calling Function to find Average
- Calculating Average
- Print the Average of three Numbers
- Program End

### Program

```
//C Program to Find the Average of Three Numbers Using Function
#include<stdio.h>
void average(int,int, int);
void main()
{
int x, y, z; //Declaring Variables
printf("Enter Three Numbers : \n");
scanf("%d %d %d",&x, &y, &z); //Input Numbers
average(x,y,z); //Calling Function to find the Average of three numbers
}
void average(int a,int b, int c)
{
float avg;
avg=(a+b+c)/3.0;
printf("Average of Three Numebers is : %f", avg);
}
```

### Output

```
Enter Three Numbers :
10
38
23
Average of Three Numebers is : 23.666666
```

## C Program to Find the Average of Three Numbers Using Array

To find the average of three numbers through an Array, first you need to know about the Array. You can read about the Array from the link given below.

- Array in C Language

### Algorithm

- Program Start
- Declaring variables
- Input Numbers
- Calculating Sum
- Calculating Average
- Print the Average of three Numbers
- Program End

### Program

```
//C Program to Find the Average of Three Numbers Using Array
#include<stdio.h>
void main()
{
//Declaring Variables
int i, sum = 0, a[3];
float avg;
printf("Enter Three Numbers : \n");
for(i=0; i<3; i++)
{
scanf("%d",&a[i]); //Input Numbers
}
for(i=0; i<3;i++)
{
sum = sum + a[i]; //Input Numbers
}
avg=sum/3.0;
printf("Average of Three Numebers is : %f", avg);
}
```

**Output **

```
Enter Three Numbers :
38
23
38
Average of Three Numebers is : 33.000000
```

## Conclusion

So friends, in this article, we have made a program to calculate the average of three numbers in three different ways.

- C Program to Find the Average of Three Numbers (Simple Way)
- C Program to Find the Average of Three Numbers using Function
- C Program to Find the Average of Three Numbers using Array

If you have difficulty to understand any program or have any doubts or questions, then tell me in the comment below.