Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

I am getting no errors but no out put for my program??

0 votes
asked Oct 22, 2017 by cypher9916190
#include <iostream>

using namespace std;

main ()
  int x, a, b, sum, diff, product, divison;
  cout << "enter a no.\n";
  cin >> a;
  cout << "enter another no. \n";
  cin >> b;
  cout << "enter the operator\n";
  cin >> x;

  if (x == sum)
      sum = a + b;
      cout << "sum=" << sum << endl;
  else if (x == diff)
      diff = a - b;
      cout << "diff=" << diff << endl;

  else if (x == product)
      product = a * b;
      cout << "product=" << product << endl;

  else if (x == divison)
      divison = a / b;
      cout << "divison=" << divison << endl;
  return 0;

when I ran this program online it gave the accurate result.... but when I tried running this program on my computer I get no output just three entries but no result

1 Answer

0 votes
answered Oct 30, 2017 by anonymous
change the sum,diff,product,division with the number because the x is an integer variable it cannot store alphabets
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.