CSE 123C.001 2-8-08

CSE 123C.001 2-8-08 - degrees to Celsius o Input/Output...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 123C February 8, 2008 Cin o Istream object o Streams input from standard input o Uses the   manipulator (input operator) o Form Cin   variable   variable; Cout o Ostream object o Streams output to standard output o Uses the   manipulator (output operator) o Form Cout   expression   expression; Expression-any C++ expression (string, constant, identifier, formula or  function call) o Example Cout   “Hello world!”; String hi = “hello world”; cout   hi \n represents the end of the line Endl 2 functions Outputting a variable
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
o Similar to hitting return (same as \n character wise) o Makes it appear (displays it on the screen and cleans the memory) Characters and input o Input operator ( ) discards the leading whitespace o Get() is used to input all characters including whitespace and end of line Example o Problem Statement Write a program which converts any give Fahrenheit temperature from
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: degrees to Celsius o Input/Output Input→ftemp Output→ctemp o Input/Output Diagram o Hand calculation ftemp=70 ctemp= (Ftemp-32) * 5/9 ctemp= (70-32) * 5/9 =21.11 o Write the algorithm Prompt user to enter ftemp Compute ctemp given the formula ftemp ctem Print temp o Write the program // Program to convert Fahrenheit temperature to Celsius. #include <iostream> using namespace std; int main () { // Declare temperature values. int ftemp; float ctemp; // Prompt user to enter ftemp. cout ≪ “Please enter temperature in Fahrenheit:”; // Accept ftemp input cin ≫ ftemp; // Convert Fahrenheit to Celsius. ctemp=ftemp-32.0 * 5.0/9.0; // Print the result. cout ≪ “Temperature in Celsius is” ≪ ctemp ≪ endl; // Exit the program. return 0; }...
View Full Document

This note was uploaded on 04/08/2008 for the course CSE 123c taught by Professor Elkarboutly during the Spring '08 term at UConn.

Page1 / 3

CSE 123C.001 2-8-08 - degrees to Celsius o Input/Output...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online