Program to find average of three numbers using function in C C++

Program to find average of three numbers using function in C C++

C-Language में function recursion किसे कहते है और इसकी क्या उपयोगिता है जानने के लिए देखें— Recursion in C

Function में call by value और call by reference क्या होता है जानने के लिए देखें—Call by value and reference

C Language में Pointer क्या प्रयोग करते हुए किसी Function को कैसे point किया जा सकता है जानने के लिए देखें—Pointer to function

Program to find average of three numbers using function in C

#include<stdio.h>
float avg(int,int,int);
int main()
{
    int a,b,c;
    printf("Enter three numbers: ");
    scanf("%d%d%d",&a,&b,&c);
    printf("Average of numbers = %f",avg(a,b,c));
    return 0;
}
float avg(int x, int y, int z)
{
    return (x+y+z)/3.0;
}

Program to find average of three numbers using function in C++

#include<iostream>
using namespace std;
float avg(int,int,int);
int main()
{
    int a,b,c;
    cout<<"Enter three numbers: ";
    cin>>a>>b>>c;
    cout<<"Average of numbers = "<<avg(a,b,c);
    return 0;
}
float avg(int x, int y, int z)
{
    return (x+y+z)/3.0;
}

Output of Program to find average of three numbers using function in C C++

C C++ program to find average of three numbers using function

More function example programs in C C++

  1. Sum of two numbers using function
  2. Swapping using function call by value
  3. Swapping using function call by reference
  4. Passing array as function argument
  5. Passing structure as function argument
  6. Pointer to Function
Share it to:

Published by

admin

I am a computer teacher, programmer and web developer