Average of 3 Numbers Program in C

In this C programming tutorial, we will learn how to find the average of 3 numbers with the help of the C programming language. What is an average of Numbers:   The Sum of all the numbers divided the number is said to be the average of the numbers. In short, It is SUM/COUNT.

C Program to Find the Average of Three Numbers

 #include<stdio.h>
 int main()
 {
 int number1,number2,number3;//declaring the 3 numbers.
 float average;
 printf("Enter first number\n");
 scanf("%d",&number1);
 printf("Enter second number\n");
 scanf("%d",&number2);
 printf("Enter third number\n");
 scanf("%d",&number3);
 average=(number1+number2+number3)/3;//sum/count
 printf("Average is %f",average);//printing the value of the avaerage
 return 0;
 }

Addition of Three Numbers Using Function in C

#include <stdio.h>
#include <conio.h>
sum(int,int,int);
void main()
{
int a,b,c,d;
clrscr();
printf("\nACCEPT VALUE FOR a,b,c:\n");
scanf("%d %d %d",&a,&b,&c);
d=sum(a,b,c);
printf("\nSUM OF %d,%d and %d IS %d",a,b,c,d);
getch();
}
sum(int x,int y,int z)
{
int temp;
temp=x+y+z;
return(temp);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Shopping cart