Answers for "average of 5 numbers in c using function"


average of 5 numbers in c using function

/* here i needed to do of 5 numbers so the array is set to store only 5 numbers
   you can set it to user desire using a varaible*/

#include <stdio.h>
#include <conio.h>

float avg();

void main ()
    printf("\nThe average of 5 numbers is %.2f\n",avg());

float avg()
    int i,num[5],sum=0;
    float average=0;

    for(i=0; i < 5; i++)
        printf("Enter number %d: ",i+1);
        sum = sum + num[i];
    average = sum / 5.0;
    return average;
Posted by: Guest on June-23-2021

c program to find average of 3 numbers

#include <stdio.h>

int main(void) 
  // these numbers can be whatever you want
  int number = 1231231;
  int number2 = 1231232;
  int number3 = 1;
  // 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.
  int average = number + number2 + number3 / 3;
  // prints the average
  printf("%i", average);
Posted by: Guest on December-16-2020

Code answers related to "average of 5 numbers in c using function"

Code answers related to "C"

Browse Popular Code Answers by Language