[ create a new paste ] login | about

Link: http://codepad.org/ebzuLdFO    [ raw code | output | fork ]

C++, pasted on Apr 7:
#include <iostream>
int main()
{ int choice ;
  double temp,conv_temp ;
  cout << "Temperature Conversion Program by Vibhu " << "\n" ;
  cout << "Choose one of the following options for conversion" << "\n" ;
  cout << "1. Fahrenheit to Celsius" << "\n" ;
  cout << "2. Celsius to Fahrenheit" << "\n" ;
  cout << "Enter your choice ( 1 or 2) : " ;
  cin >> choice;
  
  if (choice == 1) {
      cout << "\n" << "Enter temperature value in Fahrenheit : " ;
      cin >> temp;
      conv_temp = (temp - 32)/1.8;
      cout << "Temperature in Celsius is " << conv_temp << "\n" ; 
      }
      else
     (choice == 2 ); {
      cout << "\n" << "Enter Temperature value in Celsius : " ;
      cin >> temp;
      conv_temp = (1.8* temp ) + 32;
      cout << "The temperature in Fahrenheit is " << conv_temp << "\n" ;
      }
  return 0;
  }


Output:
1
2
3
4
5
6
Temperature Conversion Program by Vibhu 
Choose one of the following options for conversion
1. Fahrenheit to Celsius
2. Celsius to Fahrenheit
Enter your choice ( 1 or 2) : 
Enter Temperature value in Celsius : The temperature in Fahrenheit is 32


Create a new paste based on this one


Comments: