1/* here i needed to do of 5 numbers so the array is set to store only 5 numbers
2 you can set it to user desire using a varaible*/
3
4#include <stdio.h>
5#include <conio.h>
6
7float avg();
8
9void main ()
10{
11 printf("\nThe average of 5 numbers is %.2f\n",avg());
12}
13
14float avg()
15{
16 int i,num[5],sum=0;
17 float average=0;
18
19 for(i=0; i < 5; i++)
20 {
21 printf("Enter number %d: ",i+1);
22 scanf("%d",&num[i]);
23 sum = sum + num[i];
24 }
25
26 average = sum / 5.0;
27 return average;
28}
29
1#include <stdio.h>
2
3int main(void)
4{
5 // these numbers can be whatever you want
6 int number = 1231231;
7 int number2 = 1231232;
8 int number3 = 1;
9
10 // add up all the numbers you want to average, then divide it by the total amount of numbers. In this case there are 3 numbers, so you divide it by three.
11 int average = number + number2 + number3 / 3;
12
13 // prints the average
14 printf("%i", average);
15}