Is sum and average of two numbers a sequence program in c
Answers
Explanation:
* 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;
Answer:
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;