Theory
In this program, three variables are declared num1, num2, and num3. These variables will store three floating-point numbers. The printf function displays the messages to the user “Enter three Numbers:”. Later using scanf function three numbers are stored in the variables num1, num2, and num3.
The scanf function reads the numbers until the user enters not enters the three numbers. If the user enters integer number then it will be automatically converted to a floating-point number by type promotion.
The sum is calculated as num1+num2+num3. The values of those three variables are floating-point numbers so, their sum will be a floating-point number. The average is calculated as sum/(total numbers).
After calculating the sum and average of the numbers, the variables num1, num2, and num3 are printed. Finally, the sum and average are displayed to the screen.
In c, we can divide a large program into the basic building blocks known as function. The function contains the set of programming statements enclosed by {}. A function can be called multiple times to provide reusability and modularity to the C program. In other words, we can say that the collection of functions creates a program. The function is also known as procedureor subroutinein other programming languages.
Function declaration A function must be declared globally in a c program to tell the compiler about the function name, function parameters, and return type.
Function call Function can be called from anywhere in the program. The parameter list must not differ in function calling and function declaration. We must pass the same number of functions as it is declared in the function declaration.
Function definition It contains the actual statements which are to be executed. It is the most important aspect to which the control comes when the function is called. Here, we must notice that only one value can be returned from the function.

Example 1: C Program to Find Sum and Average of 3 Numbers
int main()
{
float num1, num2, num3;
float sum, avg;
printf("Enter three Numbers: ");
scanf("%f %f %f",&num1, &num2, &num3);
sum = num1 + num2 + num3;
avg = sum / 3;
printf("Entered numbers are: %.2f, %.2f and %.2f\n",
num1, num2, num3);
printf("Sum=%.2f\n", sum);
printf("Average=%.2f\n",avg );
return 0;
}
Example 2: the average of three given numbers using C
void main()
{
int n1,n2,n3;
float avg;
clrscr();
printf("\nENTER THREE NUMBERS: " );
scanf("%d %d %d",&n1,&n2,&n3);
avg=(n1+n2+n3)/3;
printf("\nAVERAGE: %0.2f",avg);
getch();
}
