As you can tell, I'm trying to convert inches to cm, or cm to inches, depending on the input from the user. I'm new to using char and wondering how I'm suppose to write this code. Thanks for the help.
//inches_conversion.cpp
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
int main()
{
int inches, cm; //inches & centimeters
char type, ans; //type of conversion & answer to continue/stop
float org, converted; //orginal & converted answer
ans=1;
while (ans==1)
{
cout<<"\nType C to convert to Centimeters or I to convert to Inches: ";
cin>>type;
if (type=='c' | type=='C')
{
cout<<"\nEnter the number of inches to be coverted: " << endl;
cin>>inches;
cout<<inches<<" converts to: " (inches*2.54)<<" centimeters.";
}
elseif ('i' | 'I')
{
cout<<"\nEnter the number of centimeters to be converted: " << endl;
cin>>cm;
cout<<cm<<" converts to: "<< (cm/1)<<" inches."<<endl;
}
getch();
cout<<"Do you want to make another conversion? (y/n): ";
cin>>ans;
cout<<endl;
}
return 0;
}
I entered and fixed my code based off of your reply. My errors for those specific lines are gone except for one. In this line, cout<<inches<<" converts to: " (inches*2.54)<<" centimeters."; I am getting a "call of nonfunction in function main, error. Why am I getting this?