Here, we have a basic program example to perform arithmetic function on two numbers using different languages. This program is created in c language, c++, Java, and Python.
Program to perform arithmetic functions in C language
#include <stdio.h>
int main()
{
int num1, num2, addition, subtraction, multiplication;
float division;
printf("Enter first integer: ");
scanf("%d", &num1);
printf("Enter seond integer: ");
scanf("%d", &num2);
addition = num1 + num2;
subtraction = num1 - num2;
multiplication = num1 * num2;
division = num1 / (float)num2;
printf("Sum of two numbers = %d\n",addition);
printf("Difference of two numbers = %d\n",subtraction);
printf("Multiplication of two numbers = %d\n",multiplication);
printf("Division of two numbers = %.2f\n",division);
return 0;
}
Program to perform arithmetic functions in C++ language
#include<iostream>
using namespace std;
int main(){
int num1, num2, addition, subtraction, multiplication;
float division;
cout<<"Enter first integer: ";
cin>>num1;
cout<<"Enter seond integer: ";
cin>>num2;
addition = num1 + num2;
subtraction = num1 - num2;
multiplication = num1 * num2;
division = num1 / (float)num2;
cout<<"Sum of two numbers = "<<addition<<endl;
cout<<"Difference of two numbers = "<<subtraction<<endl;
cout<<"Multiplication of two numbers = "<<multiplication<<endl;
cout<<"Division of two numbers = "<<division;
return 0;
}
Program to perform arithmetic functions in Python language
num1=int(input("Enter first integer : "))
num2=int(input("Enter second integer : "))
addition = num1 + num2
substraction = num1 - num2
multiplication = num1 * num2
division = num1 / num2
print("The sum of two numbers is:", addition)
print("The difference of two numbers is: ", substraction)
print("The multilication of two numbers is: ", multiplication)
print("The division of two numbers is: ", division)
Program to perform arithmetic functions in Java language
import java.util.*;
class operations
{
public static void main(String[] args)
{
int num1, num2, addition, subtraction, multiplication;
float division;
Scanner s=new Scanner(System.in);
System.out.println("Enter first integer :");
num1 = s.nextInt();
System.out.println("Enter second integer :");
num2 = s.nextInt();
addition = num1 + num2;
subtraction = num1 - num2;
multiplication = num1 * num2;
division = num1/num2;
System.out.println("The sum of two numbers is: " +addition);
System.out.println("The difference of two numbers is: " +subtraction);
System.out.println("The multiplication of two numbers is: " +multiplication);
System.out.println("The division of two numbers is: " +division);
}
}