Computer Science, asked by solankikanishka20, 6 months ago

write a program to print the sum
of three numbers and find their
Average.​

Answers

Answered by manavpaul27
0

Answer:

Program to print the sum of three numbers and find their average in c language

Explanation:

NOW PROGRAM

Main Menu

C Program to Find Sum and Average of 3 Numbers

Leave a Comment / C Program, C Programming / basic c programs, basics of c, c language basics, c program examples, c programming examples with output, c programs, learn c, learn c programming, Simple C programs

Develop a C program to find the sum and average of 3 numbers.

Let three numbers are a, b & c then,

Sum = (a+b+c)

and,

Average = sum/3

Program description:- Write a C program to find the sum and average of three numbers. Take inputs from the end-user.

#include<stdio.h>

int main()

{

// declare variable

float num1, num2, num3;

float sum, avg;

// take inputs

printf("Enter three Numbers: ");

scanf("%f %f %f",&num1, &num2, &num3);

// calculate sum

sum = num1 + num2 + num3;

// calculate average

avg = sum / 3;

// display entered numbers

printf("Entered numbers are: %.2f, %.2f and %.2f\n",

num1, num2, num3);

// display sum and average

printf("Sum=%.2f\n", sum);

printf("Average=%.2f\n",avg );

return 0;

}

Answered by Shivu516
0

This program is in Java.  

import java.util.*;

public class AverageCalculator {

   public static void main (String [] args) {

       //Taking input from the user

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter the first number: ");

       double num1 = sc.nextDouble();

       System.out.print("Enter the second number: ");

       double num2 = sc.nextDouble();

       System.out.print("Enter the third number: ");

       double num3 = sc.nextDouble();

       //Main part comes here

       double Average = (num1 + num2 + num3) / 3;

       double sum = num1 + num2 + num3;

       System.out.println("The sum of the following numbers is " + sum);

       System.out.println("The average of the given numbers is " + Average);

   }

}

Output:

Enter the first number: 30

Enter the second number: 31

Enter the third number: 28

The sum of the following numbers is 89.0

The average of the given numbers is 29.666666666666668

Similar questions