# C program to find SUM and AVERAGE of two numbers.

In this C program, we are going to learn how to find sum and average of two integer numbers? Here, we are taking input from the user of two integer number, first number will be stored in the variable a and second number will be stored in the variable b.

Sum of the numbers is calculating by a+b and assigning into variable sum and average of numbers in calculating by (float)(a+b)/2 and assigning to variable avg. Here, float is using to cast type.

## Sum and Average of two numbers

Note: Only integer values should be entered as input.

```/* c program find sum and average of two numbers*/
#include <stdio.h>

int main()
{
int a,b,sum;
float avg;

printf("Enter first number :");
scanf("%d",&a);
printf("Enter second number :");
scanf("%d",&b);

sum=a+b;
avg= (float)(a+b)/2;

printf("\nSum of %d and %d is = %d",a,b,sum);
printf("\nAverage of %d and %d is = %f",a,b,avg);

return 0;
}
```

Output

```    Enter first number :10
Enter second number :15

Sum of 10 and 15 is = 25
Average of 10 and 15 is = 12.500000
```

What's New

Top Interview Coding Problems/Challenges!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates