What is wrong with my program
when i run this it gives these error
Code:
calc.h(12): error C2628: 'numbers' followed by 'float' is illegal (did you forget a ';'?)
calc.h(26): error C2440: 'return' : cannot convert from 'float' to 'numbers'
well here is the header were most of the code is
Code:
#include <iostream>
#include <cmath>
using namespace std;
struct numbers
{
float x;
float y;
char a;
}
float gathering()
{
float b;
float c;
char z;
numbers numb;
cout<<"enter an operation (select o for the operations)\n";
cin>> b >> z >> c;
b = numb.x;
z = numb.a;
c = numb.y;
return c;
}
float math()
{
float answer;
numbers numb;
//this next part decides if you add, multiply, divide, or subtract depending on the input
float y;
switch (numb.a){
case 's':
answer = sqrt (numb.x);
break;
case 'x':
answer = numb.x*numb.y;
break;
case '/':
answer = numb.x/numb.y;
break;
case '+':
answer = numb.x+numb.y;
break;
case '-':
answer = numb.x-numb.y;
break;
case '^':
answer = pow (numb.x,numb.y);
break;
}
return answer;
}
and the .cpp file
Code:
#include <iostream>
#include "calc.h"
using namespace std;
int main()
{
float answer = math();
cout<< answer <<"\n";
system("pause");
}