Friday, December 13, 2019

Write a source code for C++ and Java programs to calculater "Addition,Subtraction,Multiplication,Division"?


Source code for C++  program to calculate two number "Addition,Subtraction,Multiplication,Division".

#include<iostream.h>
#include<conio.h>

void main()
{
int a,b,add,sub,multi,div;
clrscr();
cout<<"Enter two integer numbers:"  ;
cin>>a>>b;
cout<<"Addition :"  ;
cout<<add=a+b;
cout<<"Subtraction"  ;
cout<<sub=a-b;
cout<<"Mutliplication"  ;
cout<<multi=a*b;
cout<<"Division"  ;
cout<<div=a/b;

getch();
}



Source code for Java  program to calculate  two number "Addition,Subtraction,Multiplication,Division" .


import java.util.Scanner;
class calculate
{
public static void main(String []args)
{
int a,b,add,sub,multi,div;
Scanner s=new Scanner(System.in);
System.out.println("  Enter two integer numbers:"  );
a=s.nextInt( );
b=s.nextInt( );
System.out.println("  Addition :"  +(add=a+b));
System.out.println("  Subtraction:"+(sub=a-b));
System.out.println("  Mutliplication:"  +(multi=a*b));
System.out.println("  Division:"+(div=a/b));
}
}

No comments:

Post a Comment