0% found this document useful (0 votes)
15 views2 pages

For C ++write A Program That Performs All Mathematical Operations On Two Variables in C++

Uploaded by

tayyabbhatti7258
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

For C ++write A Program That Performs All Mathematical Operations On Two Variables in C++

Uploaded by

tayyabbhatti7258
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Write a Program that performs all

mathematical operations on two


variables in C/C++ Language.
For c++ language:
1. #include <iostream>
2. #include <cmath>

3. int main() {
4. double num1 = 2;
5. double num2 = 5;

6. std::cout << "First Number: " << num1 << std::endl;


7. std::cout << "Second Number: " << num2 << std::endl;

8. std::cout << "\nArithmetic Operations:" << std::endl;


9. std::cout << "------------------------" << std::endl;
10. std::cout << "Addition: " << num1 << " + " << num2 <<
" = " << num1 + num2 << std::endl;
11. std::cout << "Subtraction: " << num1 << " - " << num2
<< " = " << num1 - num2 << std::endl;
12. std::cout << "Multiplication: " << num1 << " * " << num2
<< " = " << num1 * num2 << std::endl;
13. std::cout << "Division: " << num1 << " / " << num2 << "
= " << num1 / num2 << std::endl;
14. std::cout << "Modulus: " << (int)num1 << " % " <<
(int)num2 << " = " << (int)num1 % (int)num2 << std::endl;
15. std::cout << "Power: " << num1 << " ^ " << num2 << "
= " << pow(num1, num2) << std::endl;

16. std::cout << "\nComparison Operations:" << std::endl;


17. std::cout << "-----------------------" << std::endl;
18. std::cout << "Is Equal: " << (num1 == num2) <<
std::endl;
19. std::cout << "Is Not Equal: " << (num1 != num2) <<
std::endl;
20. std::cout << "Is Greater: " << (num1 > num2) <<
std::endl;
21. std::cout << "Is Lesser: " << (num1 < num2) << std::endl;
22. std::cout << "Is Greater or Equal: " << (num1 >= num2)
<< std::endl;
23. std::cout << "Is Lesser or Equal: " << (num1 <= num2)
<< std::endl;

24. return 0;
25. }

You might also like