Answer to Question #7242 in C++ for john

Question #7242
how would you write a program which uses a 1D array to store 10 temperature readings
and that the program include 4 functions main(),controller,ctof() and ftoc().
that the program is for converting fahrenheit to celcius
with it being Fahrenheit->Celcius /5*9 +32

Celius -> (Fahrenheit-32)/9*5
1
Expert's answer
2012-03-13T08:06:52-0400
#include <iostream>

using namespace std;

float * ctof(float
* deg){
float * res = new float[10];
for( int i=0; i<n; i++
){
res[i] = deg[i] * 9 / 5 + 32;
}
return res;
}

float *
ftoc(float * deg){
float * res = new float[10];
for( int i=0; i<n; i++
){

res[i] = (deg[i]-32) * 5 / 9;
}
return res;
}

void
controller(){
float * temp = new float [n];
cout<<"Input 10 value of
tempetarute in Fahrenheit\n";
for( int i=0; i<n; i++
){
cout<<i+1<<": ";
cin>>temp[i];
}

float *
cel = ftoc(temp);
cout<<"Celcius: "<<endl;
for( int i=0;
i<n; i++ ){
cout<<i+1<<":
"<<cel[i]<<endl;

}

float * fahr =
ctof(cel);
cout<<"Fahrenheit: "<<endl;
for( int i=0; i<n;
i++ ){
cout<<i+1<<":
"<<fahr[i]<<endl;

}
}

int
main(){
controller();
system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS