How do I get the following program to work in Linux? I keep getting an error: \'
ID: 3559142 • Letter: H
Question
How do I get the following program to work in Linux? I keep getting an error: 'scanf' was not declared in this scope.
//Small Linux program that will calculate the temperature in degrees Fahrenheit, given the temperature in degrees Celsius, when c is input
#include<iostream>
using namespace std;
int main()//main function
{
double c;
double f;
int a;
while(1!=2)
{
cout<<"Enter temperature in Celsius (C): ";
cin>>c;//user inputs temperature in Celsius
f = ((c * 9)/5) + 32;//sets f to conversion equation from Fahrenheit to Celsius
cout<<" Temperature in Fahrenheit (F) is: " <<f<< " ";//Displays converted temperature in Fahrenheit
cout<<" To continue enter any number or to exit enter 0: ";
scanf("%d",&a);
if(a==0)
break;
cout<<endl;
}
return 0;
}
Explanation / Answer
Don't use scanf() instead of it use cin>>a; then there will be no more errors
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.