Pages

Friday, April 29, 2016

C program to show use of User Defined Functions.


This program demonstrate use of FindAverage() function.

#include<stdio.h>
void FindAverage(); // function prototype declaration.
int main()
{
     FindAverage(); //Call function.
     return 0;
}

void FindAverage()
{
     //function logic is written here..
     float num1, num2;
    
     printf("Enter number1: ");
     scanf("%f",&num1);
    
     printf("Enter number2: ");
     scanf("%f",&num2);
    
     printf("Average of two numbers: %f.", (num1+num2)/2);    
}
//Output
Enter number1: 10
Enter number2: 20

Average of two numbers: 15.000000.

No comments:

Post a Comment