Hello,
I'm having a problem with with code. Here is my code
Code:
#include <stdio.h>
#include <iostream>
#include namespace std
main()
{
int *num1;
int *num2;
int *op;
num1 = new int;
num2 = new int;
op = new int;
cout<<"Enter first number:"; //error: 'cout' was not declared in scope
cin>> *num1; //error: 'cin' was not declared in scope
cout<<"Enter second number:";
cin>> *num2;
while(*op != 6)
{
cout<<"1: Addition"
<<"2: Subtraction"
<<"3: Multiplication"
<<"4: Division"
<<"5: Modulus"
<<"6: Exit\n"
<<"Please enter a choice:";
cin<< *op;
switch(*op)
{
case (1):
cout<< *num1 + *num2;
break;
case (2):
cout<< *num1 + *num2;
break;
case (3):
cout<< (*num1) * (*num2);
break;
case (4):
if(*num2 == 0)
cout<<"Unable to perform division."
<< " Please enter a nonzero second number";
else
cout<< (*num1) / (*num2);
break;
case (5):
cout<< (*num1) % (*num2);
break;
case (6):
break;
default:
cout<< "Please enter valid option";
break;
}
}
}
when compiling i would get these errors
calculator.cpp: In function `int main()':
calculator.cpp:30: error: no match for 'operator<<' in 'std::cin << *op'
line 30 being any idea on what could cause this? I'm new to c++, please bare with me.