Sep 15 2009

Temp Converter

Category: C Programmingadmin @ 4:50 am

/*Convert a Celsius temperature to Fahrenhit*/
#include<stdio.h>
main()
{
      float tmpc;
      float tmpf;
      printf("Enter Celsius temperature:");
      scanf("%f",&tmpc);
      tmpf=32+tmpc*9/5;
      printf("Farenhit temperature:%.2f\n",tmpf);
 
      fflush(stdin);
      getchar();
}

Tags: , ,


Jun 11 2009

Temp Converter

Category: Javaadmin @ 12:19 am


//Purpose: Convert a Celsius temperature to Fahrenhit
 
public class tempConverter {
	public static void main(String[] args){
 
		float celsius = 100;
		float fahrenheit;
 
		//convert to Fahrenheit equivalent
		fahrenheit = 32 + ((9* celsius) / 5);
 
		System.out.println("Celsius temperature");
		System.out.println("  " + celsius);
		System.out.println("Equivalent Fahrenheit temperature");
		System.out.println("  " + fahrenheit);
		}
}

Tags: , ,