calc.h

Code:

#include <iostream>
#include <cmath>
#include <string>
using namespace std;
inline void operations()
{
cout<<"x,/,+,-,^,s(press enter then enter the number)\n";
}
inline float math()
{
string line;
float number;
float answer;
cout<<"enter what you want to do (m for math, o for math operations, s for square root, f for farenheit to celsius, c for celsius to farenheit)\n";
getline(cin,line);
if(line.at(0) == 'o'){
operations();
answer = 0;
return answer;
}
if(line.at(0) == 's'){
cout<<"enter a number: ";
cin>>number;
answer = sqrt(number);
return answer;
}
if(line.at(0) == 'm'){
float x;
float y;
char a;
float answer;
cout<<"enter a problem\n";
cin>>x>>a>>y;
switch (a){
case 'x':
answer = x*y;
return answer;
break;
case '/':
answer = x/y;
return answer;
break;
case '+':
answer = x+y;
return answer;
break;
case '-':
answer = x-y;
return answer;
break;
case '^':
answer = pow (x,y);
return answer;
break;
}
}
if(line.at(0) == 'c'){
float degrees;
cout<<"enter degrees celsius\n";
cin>> degrees;
answer = 1.8*degrees+32;
return answer;
}
if(line.at(0) == 'f'){
float degrees;
cout<<"enter degrees farenheit\n";
cin>> degrees;
answer = (degrees-32)*1.8;
return answer;
}
int main();
}

main.cpp

Code:

#include <iostream>
#include "calc.h"
using namespace std;
int main()
{
float answer = math();
char yn;
cout<< answer <<"\n";
cout<<"do you want to calculate something else?<y/n>\n";
cin>>yn;
if(yn == 'y'){
math();
}
if(yn == 'n'){
return 1;
}
}

When i press y to loop the program the program crashed, any suggestions?

Thank you.