average of 5 numbers in c using function

Solutions on MaxInterview for average of 5 numbers in c using function by the best coders in the world

showing results for - "average of 5 numbers in c using function"
Adil
30 Aug 2018
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
Flo
29 Feb 2018
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}
queries leading to this page
c program to find average of 5 numbersprogram to find sum and average of three numbersaverage of two number in cc program average of two numbers using functionprogram to find sum and average of three numbers in c languageaverage of numbers in cwrite a c program to find the average of 5 numbers and the number is given by the userwrite a program to find average of 3 numberaverage 3 numbers c programmingaverage of 3 numbers decimal in caverage of two numbers in caverage of 5 numbers in cc program that computes sum and average of three numbersaverage of three numbers in cc code for average of n numbersaverage of n numbers in caverage of 3 numbers in caverage of five number using function in cc program to calculate sum and average of three integeraverage 3 float number in c write a c program to find the average of any given three numbers using while statementwrite a program in c to calculate the average of five numbers using the function write a c program to find the average of two numbers find the average of 5 numbers for loop c programmingaverage of 5 numbers in c using functionc program to find average of 5 numbers using functionaverage of 3 number cc program to find minimum number using functionhow to find the average of ten numbers in ccalculate average of n numbers in cc program calculate average and sum of 5 numbersc program to find averagewrite a program to find average of n numbers in cc program to find average of 3 numbersaverage of 3 numbers in c using functionwrite a c program to find the average of any given three numbersaverage of 3 number in caverage of 5 numbers in c using function