Basics of Most C++ Programs. 01. // Programmer: Clayton Price date: 9/4/10 02. // File: fahr2celc.cpp 03. // Purpose:

Slides:



Advertisements
Similar presentations
TEMPERATURE CONVERSION
Advertisements

CSE 251 Dr. Charles B. Owen Programming in C1 Functions.
Chapter 8 Scope, Lifetime and More on Functions. Definitions Scope –The region of program code where it is legal to reference (use) an identifier Three.
CS1010 Programming Methodology
Classes. COMP104 Lecture 25 / Slide 2 Motivation  Types such as int, double, and char are simple objects. * They can only answer one question: “What.
Classes. COMP104 Class / Slide 2 Motivation  Types such as int, double, and char are “stupid” objects. * They can only answer one question: “What value.
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
CS 1400 Chapter 5, section 2. Loops! while (rel-expression)while (rel-expression) {statements statement } if the relational-expression is true, execute.
Prof. Béat Hirsbrunner Fulvio Frapolli, PhD Student (exercises) Bachelor students : - Major in computer science (first year, 2nd term) - Major in information.
Computer Science 1620 Lifetime & Scope. Variable Lifetime a variable's lifetime is finite Variable creation: memory is allocated to the variable occurs.
Chapter 6: Functions.
Software Engineering 1 (Chap. 1) Object-Centered Design.
Computer Programming Lab(4).
Program State and Program Execution CSE 1310 – Introduction to Computers and Programming 1.
Functions.
The switch Statement Selection Revisited. Problem Using OCD, design and implement a program that allows the user to perform an arbitrary temperature conversion.
PRINCIPLES OF PROGRAMMING Revision. A Computer  A useful tool for solving a great variety of problems.  To make a computer do anything (i.e. solve.
1 Programming and Problem Solving — Software Engineering (Read Chap. 2)
Programming and Problem Solving — Software Engineering (Read Chap. 2) 1.
Variables, Data Types and Constants Yared Semu Addis Ababa Institute of Technology Mar 31, 2012.
Chapter 2 Overview of C Instructor: Kun-Mao Chao ( 台大資工 趙坤茂 )
Bell Ringer What types are numbers are there is the python programming language?
Chapter 5 Functions For All Subtasks. Void functions Do not return a value. Keyword void is used as the return type in the function prototype to show.
Multiple Files. Monolithic vs Modular  one file before  system includes  main driver function  prototypes  function.
CSC 221: Computer Programming I Fall 2001  C++ basics  program structure: comments, #include, main, return  output: streams, cout, endl  input: variables,
C++ Programming: Basic Elements of C++.
Type Conversions Implicit Conversion Explicit Conversion.
Fundamental Programming: Fundamental Programming Introduction to C++
1 CS161 Introduction to Computer Science Topic #3.
Temperature Conversions
Chapter 3: Modifying objects Operators and Expressions JPC and JWD © 2002 McGraw-Hill, Inc. Modified by S. Sudarshan.
More about Java Chapter 2 9/8 & 9/9 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Lesson 4 Input. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are using. The reason it is not.
Input a number #include using namespace std; int main() { int num; cout num; return 0; }
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
Variables and Assignment CSIS 1595: Fundamentals of Programming and Problem Solving 1.
ITEC 109 Lecture 7 Operations. Review Variables / Methods Functions Assignments –Purpose? –What provides the data? –What stores the data? –What type of.
Lecture 4 Function example. Example1 int max (int a, int b) { int c; if (a > b) c = a; else c = b; return (c); } void main ( ) {int x, y; cin>>x>>y; cout.
Quiz 2 Results. What Is Wrong? #include using namespace std int Main() { // Say Hello 4 times for(i == 0; i < 3; i++) { cout >> "Hello World!"
INPUT & VARIABLES.
Celsius and Fahrenheit
11/10/2016CS150 Introduction to Computer Science 1 Last Time  We covered “for” loops.
Modular Programming – User Defined Functions. CSCE 1062 Outline  Modular programming – user defined functions  Value returning functions  return statement.
Interpreting Temperature Logger Data
Today in CS161 Lecture #5 Learn about… Data types (char, int, float) Input and Output (cin, cout) Writing our First Program Write the Inches to MM Program.
COMP 110: Spring Announcements Lab 1 due Wednesday at Noon Assignment 1 available on website Online drop date is today.
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
1 CS 1430: Programming in C++. 2 Input: Input ends with -1 Sentinel-Controlled Loop Input: Input begins with.
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
Temperature.
Homework 1 (due:April 8th) Deadline : April 8th 11:59pm Where to submit? eClass “ 과제방 ” ( How to submit? Create a folder. The name.
Temperature Measurement
CS 115 Lecture 5 Math library; building a project Taken from notes by Dr. Neil Moore.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
General Computer Science for Engineers CISC 106 Lecture 27 Dr. John Cavazos Computer and Information Sciences 04/27/2009.
CS 240 Computer Programming 1
Python Programming Module 3 Functions Python Programming, 2/e1.
DEVRY COMP 122 Lab 4 Lab Report and Source Code Check this A+ tutorial guideline at
C++ Basics Lecture 2.
TEMPERATURE CONVERSION
Function Basics.
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
Lecture 12 Oct 16, 02.
PLC 5 and ControlLogix Subroutine Parameters
CS150 Introduction to Computer Science 1
Mr. Dave Clausen La Cañada High School
CS150 Introduction to Computer Science 1
Life is Full of Alternatives
Multiple Files Revisited
Presentation transcript:

Basics of Most C++ Programs

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

01. // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose: this file contains the main function of the program which will input 04. // Fahrenheit temps from the user, then convert and output Celsius to same #include 07. using namespace std; int main() 10. { 11. /* DECLARATIONS */ 12. float celc; // output variable 13. float fahr; // input variable /* GREETINGS AND INPUT */ 16. cout<<”\t\tWelcome to Temperature Conversion Program”<<endl<<endl; 17. cout<<”Please enter a temperature in Fahrenheit: “; 18. cin>>fahr; /* COMPUTATIONS AND OUTPUT */ 21. celc = (5.0/9)*(fahr – 32); 22. cout<<”\n\nYour temperature input of “<<fahr<<” degrees Fahrenheit is “ 23. << celc<<” degrees celcius”<<endl; 24. cout<<”Have a nice day”<<endl; return 0; 27. }

End of Session