Error compliling/running C++ program
Dear/s,
I am trying to run the following C++ program in Ubuntu 8.10,
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
using namespace std;
void c_to_f(void);
void f_to_c(void);
void
main(void)
{
int choice;
char again;
do
{
system("CLS");
cout<<setw(10)<<" "<< "What conversion would you like to make?\n";// menu
cout<<setw(20)<<" "<< "1. Celsius to Fahrenhei\n\n";
// make a choice which functions to use.
cout<<setw(20)<<" "<< "2. Fahrenheit to Celsius\n\n";
cin>>choice;
switch(choice)
// go to chosen function
{
case 1:
{
c_to_f();
break;
}
case 2:
{
f_to_c();
break;
}
default:
{
cout<
// validate and correct input of function choice.
}
}
cout<<setw(10)<<" "<< "Do you wish to do another conversion? y for yes, n for no "; // return loop on y for yes.
cin>> again;
}while (again=
}
void c_to_f(void)
{
system("CLS"); //clean screen for function data.
int temp,fahrenheit;
cout<< "\n\n\n ";
cout<<setw(10)<<" "<< "Enter the temperature in whole degress Celsius. \a";
cin>>temp;
fahrenheit=
cout<<
}
void f_to_c(void)
{
system("CLS"); // clear screen for function data.
int temp, celsius;
cout<< "\n\n\n ";
cout<<setw(10)<<" "<< "Enter the temperature in whole degrees fahrenheit. \a";
cin>>temp;
celsius=
cout<<
}
But when I try to compile/run I get the following errors;
bharat@
Temp.cpp:1:22: error: iostream.h: No such file or directory
Temp.cpp:2:21: error: iomanip.h: No such file or directory
Temp.cpp:64: error: stray ‘\’ in program
Temp.cpp:64: error: stray ‘\’ in program
Temp.cpp:64: error: stray ‘\’ in program
Temp.cpp:64: error: stray ‘\’ in program
Temp.cpp:64:79: warning: missing terminating " character
Temp.cpp:64: error: missing terminating " character
Temp.cpp:9: error: ‘::main’ must return ‘int’
Temp.cpp: In function ‘int main()’:
Temp.cpp:17: error: ‘cout’ was not declared in this scope
Temp.cpp:17: error: ‘setw’ was not declared in this scope
Temp.cpp:21: error: ‘cin’ was not declared in this scope
Temp.cpp:38: error: ‘endl’ was not declared in this scope
Temp.cpp:48: error: lvalue required as left operand of assignment
Temp.cpp:48: error: expected `)' before ‘;’ token
Temp.cpp: In function ‘void c_to_f()’:
Temp.cpp:58: error: ‘cout’ was not declared in this scope
Temp.cpp:59: error: ‘setw’ was not declared in this scope
Temp.cpp:60: error: ‘cin’ was not declared in this scope
Temp.cpp:64: error: ‘endl’ was not declared in this scope
Temp.cpp:64: error: expected `;' before ‘a’
Temp.cpp: In function ‘void f_to_c()’:
Temp.cpp:72: error: ‘cout’ was not declared in this scope
Temp.cpp:73: error: ‘setw’ was not declared in this scope
Temp.cpp:74: error: ‘cin’ was not declared in this scope
Temp.cpp:77: error: ‘endl’ was not declared in this scope
Temp.cpp:77: error: expected `;' before ‘temp’
bharat@
Please guide how to resolve/compile/run this program,
Thanking you,
Bharat
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Siyan Panayotov
- Solved:
- Last query:
- Last reply: