/**
http://kuntoaji.blogspot.com
*/
#include <stdio.h>
void converter(float temp, char temp_type) {
float result;
if (temp_type == 2) {
result = ((9 * temp) / 5) + 32;
printf("\nResult = %.2f Fahrenheit\n", result);
} else {
result = (temp / 5) * 4;
printf("\nResult = %.2f Reamur\n", result);
}
}
int main(void) {
float c;
int temp_type;
printf("---------------------------------------------------\n");
printf("celciusconv.c\n");
printf("Convert Celcius temperature to Reamur or Fahrenheit\n");
printf("---------------------------------------------------\n\n");
printf("Celcius temperature: ");
scanf("%f", &c);
printf("Convert to Reamur/Fahrenheit (1 / 2): ");
scanf("%d", &temp_type);
if ((temp_type == 1) || (temp_type == 2)) {
converter(c, temp_type);
} else {
printf("\nUnknown...Plase input 1 or 2");
}
return 0;
}</stdio.h>
Wednesday, February 29, 2012
C - Celcius Converter
Description: Convert Celcius to Fahrenheit or Reamur
Artikel Terkait
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment