C++ program to perform arithmetic operations by accepting inputs from a user
kw.cpp
#include<iostream>usingnamespacestd;intmain(){floata,b;cout<<"———————————————————————————————————————————";cout<<"\nProgram to perform the arithmetic operations";cout<<"\n———————————————————————————————————————————";cout<<"\nEnter the 1st number ";cin>>a;cout<<"\nEnter the 2nd number ";cin>>b;cout<<"——————————————————————————";cout<<"\nAddition | "<<a<<"+"<<b<<"="<<a+b;cout<<"\nSubtraction | "<<a<<"-"<<b<<"="<<a-b;cout<<"\nMultiplication | "<<a<<"*"<<b<<"="<<a*b;cout<<"\nDivision | "<<a<<"/"<<b<<"="<<a/b;cout<<"\n——————————————————————————";cout<<"\nAverage of 2 numbers is "<<(a+b)/2;cout<<"\n———————————————————————————————————————————\n";return0;}
Output
kodingwindow@kw:~$ g++ kw.cpp kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to perform the arithmetic operations
———————————————————————————————————————————
Enter the 1st number 1
Enter the 2nd number 0
——————————————————————————
Addition | 1+0=1
Subtraction | 1-0=1
Multiplication | 1*0=0
Division | 1/0=inf
——————————————————————————
Average of 2 numbers is 0.5
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.