Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Chargement dans…3
×

## Consultez-les par la suite

1 sur 2 Publicité

Write a program that convert integer Fahrenheit temperature to Celsius or Celsius to Fahrenheit. Use floating points with 3-digit precision. Your program should 1- Prompt to CF or FC. Where CF converting Celsius to Fahrenheit and FC to convert for converting from Fahrenheit to Celsius. 2- Once you are ready to enter CF or FC, then Enter FC and then enter 5 testing values all at once and hit enter to give the final answers in two colmuns Column 1: Your entered values and Column 2: Your converted value. Repeat step a for CF a. b. Commands (paste text not picture Output (paste picture
Solution
#include <stdio.h>
#include <string.h>
int main(){
char choice[2];
double temperature[5];
int i;
while(1){
printf(\"Enter CF or FC: \");
scanf(\"%s\", choice);
if(strcmp(choice, \"CF\") != 0 && strcmp(choice, \"FC\") != 0) break;
printf(\"Enter 5 temperatures\ \");
for(i = 0; i < 5; i++){
scanf(\"%lf\", &temperature[i]);
}
if(strcmp(choice, \"CF\") == 0){
printf(\"Celsius\\tFahrenheit\ \");
}
else printf(\"Fahrenheit\\tCelsius\ \");
for(i = 0; i < 5; i++){
printf(\"%.3lf\\t\", temperature[i]);
if(strcmp(choice, \"CF\") == 0){
printf(\"%.3lf\ \", temperature[i] * 1.8 + 32);
}
else printf(\"%.3lf\ \", (temperature[i] - 32) / 1.8);
}
}
}
.

Write a program that convert integer Fahrenheit temperature to Celsius or Celsius to Fahrenheit. Use floating points with 3-digit precision. Your program should 1- Prompt to CF or FC. Where CF converting Celsius to Fahrenheit and FC to convert for converting from Fahrenheit to Celsius. 2- Once you are ready to enter CF or FC, then Enter FC and then enter 5 testing values all at once and hit enter to give the final answers in two colmuns Column 1: Your entered values and Column 2: Your converted value. Repeat step a for CF a. b. Commands (paste text not picture Output (paste picture
Solution
#include <stdio.h>
#include <string.h>
int main(){
char choice[2];
double temperature[5];
int i;
while(1){
printf(\"Enter CF or FC: \");
scanf(\"%s\", choice);
if(strcmp(choice, \"CF\") != 0 && strcmp(choice, \"FC\") != 0) break;
printf(\"Enter 5 temperatures\ \");
for(i = 0; i < 5; i++){
scanf(\"%lf\", &temperature[i]);
}
if(strcmp(choice, \"CF\") == 0){
printf(\"Celsius\\tFahrenheit\ \");
}
else printf(\"Fahrenheit\\tCelsius\ \");
for(i = 0; i < 5; i++){
printf(\"%.3lf\\t\", temperature[i]);
if(strcmp(choice, \"CF\") == 0){
printf(\"%.3lf\ \", temperature[i] * 1.8 + 32);
}
else printf(\"%.3lf\ \", (temperature[i] - 32) / 1.8);
}
}
}
.

Publicité
Publicité