Sum and product of real numbers#8604

Sum and product of real numbers (شرح الحلول)

In this problem, you need to read three real numbers, compute and print their sum and product.

Algorithm realization

Read three real numbers.

scanf("%lf %lf %lf", &a, &b, &c);

Compute and print the sum and the product of three numbers.

s = a + b + c;
p = a * b * c;
printf("%.4lf %.4lf\n", s, p);

Java realization

import java.util.Scanner;

class Main 
{
  public static void main(String[] args) 
  {
    Scanner con = new Scanner(System.in);
    double a = con.nextDouble();
    double b = con.nextDouble();
    double c = con.nextDouble();

    double s = a + b + c;
    double p = a * b * c;

    System.out.printf("%.4f %.4f",s,p);
    con.close();
  }
}

Python realization

Read three real numbers.

a, b, c = map(float, input().split())

Compute and print the sum and the product of three numbers.

print(a + b + c, a * b * c)