Computer Science, asked by career4dilippaswan, 5 months ago


6. Write a program to accept two numbers and display their sum.

Answers

Answered by GirishHolla
1

Answer:

Method 1:

class sum

{

       public static void main(double a, double b)

       {

                 double sum = a + b;

                 System.out.println("Sum of the numbers =" + sum);          

         }

}

Method 2:

import java.util.*;

class sum

{

       public static void main()

       {

                 Scanner sc = newScanner(System.in);

                 System.out.println("Enter the first number");

                 double a = sc.nextDouble();

                 System.out.println("Enter the second number");

                 double b = sc.nextDouble();

                 double sum = a + b;

                 System.out.println("Sum of the numbers =" + sum);          

         }

}

Answered by keerthikarls2020
0

Answer:

#include <stdio.h>

int main()

{

int x, y, sum;

printf("\nInput the first integer: ");

scanf("%d", &x);

printf("\nInput the second integer: ");

scanf("%d", &y);

sum = x + y;

printf("\nSum of the above two integers =

%d\n", sum);

return 0;

}

C language

Python Program to Add Two Numbers

a = int(input("enter first number: "))

b = int(input("enter second number: "))

sum = a + b

print("sum:", sum)

MARK Me AN BRAINLIST

Similar questions