Q:

Write a C program to find SUM and AVERAGE of two numbers

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now