# Write a C C++ program to find average of three numbers

## Write a C C++ program to find average of three numbers

Procedure Oriented Programming (POP) और Object Oriented Programming (OOP) में अंतर जानने के लिए देखें—POP vs OOP

C और C++ दोनों भाषाओं में महत्वपूर्ण अंतर क्या है जानने के लिए देखें—C vs C++

### C program to find average of three numbers

``````#include<stdio.h>
int main()
{
int n1,n2,n3;
float avg;
printf("Enter number1: ");
scanf("%d",&n1);
printf("Enter number2: ");
scanf("%d",&n2);
printf("Enter number3: ");
scanf("%d",&n3);
avg=(n1+n2+n3)/3.0;
printf("Average of numbers = %f",avg);
return 0;
}``````

### C++ program to find average of three numbers

``````#include<iostream>
using namespace std;
int main()
{
int n1,n2,n3;
float avg;
cout<<"Enter number1: ";
cin>>n1;
cout<<"Enter number2: ";
cin>>n2;
cout<<"Enter number3: ";
cin>>n3;
avg=(n1+n2+n3)/3.0;
cout<<"Average of numbers = "<<avg;
return 0;
}``````

### Output of C C++ program to find average of three numbers

```Enter number1: 30
Enter number2: 90
Enter number3: 60
Average of numbers = 60.000000```
```Enter number1: 3
Enter number2: 4
Enter number3: 7
Average of numbers = 4.66667```

### Some other related programs in C C++

Share it to: 