예제 #1
0
int main(int argc, char *argv[])
{
    char *p;
    float k;
    int c, temperature;
    
    // Correct number of arguments
    if(argc != 2) {
        printf("Usage: ./temp_converter <integer>\n");
        exit(1);
    } 
    
    long conv = strtol(argv[1], &p, 10);
    
    if(errno != 0 || *p != '\0' || conv > INT_MAX) {
        printf("Error converting string -> integer. Exiting.\n");
        exit(1);
    } else {
        // Convert the integer
        temperature = conv;
        c = celsius(temperature);
        k = kelvin(temperature);
        printf("Fahrenheit: %d\n", temperature);
        printf("Celsius: %d\n", c);
        printf("Kelvin: %f\n", k);
        return 0;
    }
}
예제 #2
0
파일: 1.15.c 프로젝트: mlpinit/KR-ANSIC
int main() {
    int fahr;

    printf("Fahr Celsius\n");
    for (fahr = LOWER; fahr <= UPPER; fahr += STEP)
        printf("%4d %7.1f\n", fahr, celsius(fahr)); 

    return 0;
}
예제 #3
0
int main()
{
  double f;

  for(f = -40; f <= 220; f = f + 10)
    printf("%f\t%f\n", f, celsius(f));

  return 0;
}
예제 #4
0
파일: 1-15.c 프로젝트: ccavxx/Fragment
/* note */
main()
{
    float fahr;

    printf("\ttemperature\n");
    for (fahr  = 0; fahr <= 300; fahr += 20) {
        printf("%3.0f\t%6.1f\n", fahr, celsius(fahr));
    }
    return 0;
}
예제 #5
0
main()
{
	float fahr;
	int step = 20;
	int upper = 300, lower = 0;
	printf("Temperature Conversion\n\n");
	printf("Fahrenhiet celsius\n");
	for(fahr = lower; fahr <= upper; fahr = fahr + step)
		printf("%8.1f %8.1f\n",fahr ,celsius(fahr));
}
void printFilas(int opcion){
	if (opcion == 1){
		printf("Fahrenheit a Centigrados\n" );
		for (int fahr = 0;  fahr <= 300; fahr = fahr + 20 )
			printFila(fahr, celsius(fahr));
	}
	else{
		printf("2.--Centigrados a Fahrenheit\n" );
		for (int celsius = 0;  celsius <= 300; celsius = celsius + 20 )
			printFila(celsius, fahrenheit(celsius));
	}
}
예제 #7
0
int main(){
	int farenheit;
	int step,lower,upper;
		
	farenheit = LOWER;
	printf("Farenheit\tCelsius\n");
	while( farenheit <= UPPER )
	{
		printf("%9d\t%2.2f\n", farenheit, celsius(farenheit));
		farenheit += STEP;
	}
}
예제 #8
0
파일: Source.cpp 프로젝트: ArnoldHou/CPP
int main(void) {
	printf("¢XC\t¢XF\n");
	for (int i = 0; i <= 100; i++) {
		printf("%d\t%.1f\n", i, fahrenheit(i));
	}
	puts("");
	printf("¢XF\t¢XC\n");
	for (int i = 32; i <= 212; i++) {
		printf("%d\t%.1f\n", i, celsius(i));
	}
	puts("");
}
예제 #9
0
/*wypisz zestawienie temperatur Fahrenheita-Celsjusza
  dla fahr = 0, 20, ..., 300; wersja zmiennoprzecinkowa*/
main()
{
	float fahr;
	int lower, upper, step;

	lower = 0;	/*dolna granica temperatur*/
	upper = 300;	/*górna granica temperatur*/
	step = 20;	/*rozmiar kroku*/

	fahr = lower;
	while (fahr <= upper) {
		printf("%3.0f  %6.1f\n", fahr, celsius(fahr));
		fahr = fahr + step;
	}
}
예제 #10
0
float kelvin(int temperature)
{
    float kelvin = celsius(temperature) + 273.15;
    return kelvin;
}
예제 #11
0
 constexpr operator int() const { return celsius(); }