Question

Write an interactive C++ program which reads two integer numbers x and y, and an operator. It then performs the following operations :
(i) x + y
(ii) x — y
(iii) x * y
(iv) x / y
If any other operator is entered, the program prints out an error message.

31 Jul 2018
Answer :
Word Count : 582

Below is an interactive C++ program that reads two integer numbers, `x` and `y`, and an operator. The program performs the specified operations based on the operator entered, and it displays an error message if an invalid operator is entered.

```cpp
#include <iostream>
using namespace std;

int main() {
    // Declare variables to store the two integers and the operator
    int x, y;
    char op;

    // Input: Read two integers and an operator
    cout << "Enter two integers: ";
    cin >> x >> y;
    
    cout << "Enter an operator (+, -, *, /): ";
   

_________ _____ ____ __________ ______ ________.
______ _________ ______ __________ ____ _____ _________.
_________ __________ ________ _____ ________ ______.
______ ____ ___ _________ _________ _______ ________ ___ __________.
__________ _________ _______ ________ ______ ___ ___ ___ ____ _________ ________.
______ _________ _________ _______ _______ _______ ______ ____ _________.
____ _______ ________ ___ _____ ________ _____ ________ ____ ____ ______ ___.
________ ______ _____ ____ ________ _______ ______ ________ ______ _____ _________ ___.
______ ______ _______ ___ ________ _________.
___ ________ ____ __________ ____.
___ ________ __________ _________ ________ ______ ________ __________ ___ _______.
__________ __________ _______ ___ ______ __________ ___.
____ _________ _____ ___ ____ ________ ________ ____ _____ ______.
________ ____ __________ __________ _____ ______ _______.
________ ______ _____ ______ ___ ________ __________ ____ ___ ______ __________.
_____ ___ _________ ______ _____ ___.
________ ________ _______ _______ ________ ____.
___ _______ ______ ________ ______ ______ _______ _______ ______ ______ __________ _________.
______ ________ ______ ____ __________ _________ ______ _______.
________ ____ __________ _______ ____ __________ ____ __________ _________.
____ ____ ____ ______ ____ ____ _____ ___.
__________ ___ ___ _____ ______ __________ ______ _________ _________.
_________ __________ ___ _______ __________ ________ ___.
___ __________ ______ ____ ______ ____ ______ ______ _____.
____ _________ _________ ____ _________ ____.
______ ______ ____ ______ _________ _________ _____ _____ __________ _____ _________ ______.
______ _____ _____ _____ ______ _________.
____ ____ _________ ________ ____ ___ ___ __________ ___ ___ ___ _____.
______ _____ _______ __________ ________ ___ _____ ___ ___ ___ ___.
_______ _________ _______ __________ ___ __________ ___ _________ __________ ______.
____ ___ ___ ___ _______ _______ ___ ________ _____.
_________ __________ ______ _________ ________ _______ _________.
___ ____ ______ _______ __________ _________ _____ _______ __________ ___ ___ ______.
___ ________ ________ ______ ____ ___ _________ ______.
_________ ________ ____ _____ ________.
________ ___ _______ __________ __________ __________.
_____ ________ ___ _________ _______ _______ ____ _______ _________.
_______ _______ ______ _________ ___ ________ _____ __________.
_____ _________ _______ _____ ____ ________ ________.
____ ____ __________ _______ ________ ___.
_____ ______ __________ _____ _____ _________ ______ ____ _______.
__________ ______ ____ ______ _________ _______ __________ _____ ______ _______ ________ _____.
_____ ___ _____ ___ _____ __________ __________ __________.
_________ _____ ________ _______ __________ ___.
________ _____ ____ ________ _____ _________ ___ _________ _________ ___ _________.
__________ ________ _________ ____ _________.
___ _______ _________ _________ ____ __________.
___ ________ _______ ______ _______.
_____ ________ ________ _____ ____ _________ _____ _________ _______ _____ _________ ______.
__________ ________ _________ _______ _____ _____ _____.
________ __________ ____ _______ _____.
__________ ___ _____ ________ ____ ___ ______ ________.
______ _____ _______ ____ _________ ____ _________ _______ __________ __________.
______ ___ _______ _____ ___ ______ ________ ________ ________ _____ ________ _______.
_____ __________ ________ ____ _________ _________ ____ _______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU BCS 31 2016 - Write an interactive C++ program which reads two integer numbers x and | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→