Math, asked by aaditya3045, 6 months ago

write a program to print the addition and subtraction of two arbitrary numbers​

Answers

Answered by iagarwal
1

Answer:

Class add_sub

{

        public static void main()

        {

              System.out.println("Enter 2 numbers.");

              int x = sc.nextInt; int y = sc.nextInt;

              System.out.println("Addition = "x+y);

              System.out.println("Subtraction = "x-y);

       }

}

Answered by PravinRatta
2

C++ program to print the addition and subtraction of two arbitrary numbers​ is as follows:

#include<iostream>

using namespace std;

int main(){

int a, b;                          /*Initializing two variables*/

int sum;

int difference;        

/*we have considered sum and difference as integers*/

cout<<"Enter first number a: "<<endl;

/*Cout statements are print statements in C++ */

cin>>a;

cout<<" Enter second number b: "<<endl;

cin>> b;

/*Cin statements are used to take user inputs*/

sum = a + b;

difference=a - b;

cout<<"Sum of two arbitrary numbers is: "<<sum<<endl;

cout<<"Difference of two arbitrary numbers is: "<<difference<<endl;

return 0;

}

Hence, the difference and sum of the two numbers would print.

Similar questions