All pastes #761928 Raw Edit

Untitled

public c v1 · immutable
·published 2007-11-05 04:36 UTC
rendered paste body
#include <stdio.h>#include <string.h>float celtofah(float x){	return (x * 9/5) + 32; }float celtokelv(float x){        return x + 273.15;}float celtorank(float x){	return (celtofah(x)) + 459.67;}float fahtocel(float x){	return (x - 32) * 5/9;}float fahtokelv(float x){        return (fahtocel(x)) + 273.15;}float fahtorank(float x){	return x + 459.67;}float kelvtocel(float x){        return x - 273.15;}float kelvtofah(float x){        return celtofah((kelvtocel(x)));}float kelvtorank(float x){	return (kelvtofah(x)) + 459.67;}float ranktocel(float x){	return fahtocel(x - 459.67);}float ranktofah(float x){	return x - 459.67;}float ranktokelv(float x){	return fahtokelv(x - 459.67);}int main(void){	char choice[2];	float num = 0;	while ( (strcasecmp("q", choice)) != 0 )	{		strcpy(choice, "");		printf("1. Celsius.\n");		printf("2. Fahrenheit.\n");		printf("3. Kelvin\n");		printf("4. Rankine\n");		printf("Q to quit.\n");		printf("Input:");		scanf("%s", &choice);			if ((strcmp("1", choice)) == 0)		{			printf("1. Fahrenheit.\n");			printf("2. Kelvin.\n");			printf("3. Rankine.\n");			printf("Output:");			scanf("%s", &choice);			if ((strcmp("1", choice)) == 0)			{				printf("Please enter Celsius number for conversion:");				scanf("%f", &num);				printf("%g Degrees Fahrenheit\n", (celtofah(num)));			}			if ((strcmp("2", choice)) == 0)			{				printf("Please enter Celsius number for conversion:");				scanf("%f", &num);				printf("%g Degrees Kelvin\n", (celtokelv(num)));							}			if ((strcmp("3", choice)) == 0)			{				printf("Please enter Celsius number for conversion:");				scanf("%f", &num);				printf("%g Degrees Rankine\n", (celtorank(num)));			}		}				if ((strcmp("2", choice)) == 0)		{			printf("1. Celsius\n");			printf("2. Kelvin\n");			printf("3. Rankine\n");			printf("Output:");			scanf("%s", &choice);						if ((strcmp("1", choice)) == 0)			{				printf("Please enter Fahrenheit number for conversion:");				scanf("%f", &num);				printf("%g Degrees Celsius\n", (fahtocel(num)));			}						if ((strcmp("2", choice)) == 0)			{				printf("Please enter Fahrenheit number for conversion:");				scanf("%f", &num);				printf("%g Degrees Kelvin\n", (fahtokelv(num)));			}						if ((strcmp("3", choice)) == 0)			{				printf("Please enter Fahrenheit number for conversion:");				scanf("%f", &num);				printf("%g Degrees Rankine\n", (fahtorank(num)));			}		}		if ((strcmp("3", choice)) == 0)		{			printf("1. Celsius\n");			printf("2. Fahrenheit\n");			printf("3. Rankine\n");			printf("Output:");			scanf("%s", &choice);			if ((strcmp("1", choice)) == 0)			{				printf("Please enter Kelvin number for conversion:");				scanf("%f", &num);				printf("%g Degrees Celsius\n", (kelvtocel(num)));							}			if ((strcmp("2", choice)) == 0)			{				printf("Please enter Kelvin number for conversion:");				scanf("%f", &num);				printf("%g Degrees Fahrenheit\n", (kelvtofah(num)));			}			if ((strcmp("3", choice)) == 0)			{				printf("Please enter Kelvin number for conversion:");				scanf("%f", &num);				printf("%g Degrees Rankine\n", (kelvtorank(num)));			}		}		if ((strcmp("4", choice)) == 0)		{                        printf("1. Celsius\n");                        printf("2. Fahrenheit\n");                        printf("3. Kelvin\n");                        printf("Output:");			scanf("%s", &choice);			if ((strcmp("1", choice)) == 0)			{				printf("Please enter Rankine number for conversion:");				scanf("%f", &num);				printf("%g Degrees Celsius\n", (ranktocel(num)));			}			if ((strcmp("2", choice)) == 0)			{				printf("Please enter Rankine number for conversion:");				scanf("%f", &num);				printf("%g Degrees Fahrenheit\n", (ranktofah(num)));			}			if ((strcmp("3", choice)) == 0)			{				printf("Please enter Rankine number for conversion:");				scanf("%f", &num);				printf("%g Degrees Kelvin\n", (ranktokelv(num)));			}		}		}	return 0;}