Odds and Ends.

Slides:



Advertisements
Similar presentations
This Time Whitespace and Input/Output revisited The Programming cycle Boolean Operators The “if” control structure LAB –Write a program that takes an integer.
Advertisements

Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
1 Objectives Understand streamed input and output.
Announcements Quiz 1 Next Week. int : Integer Range of Typically -32,768 to 32,767 (machine and compiler dependent) float : Real Number (i.e., integer.
Character I/O. COMP104 Character I/O Slide 2 Data Type: char * Constant declaration const char star = '*'; * Variable declaration char resp; * Variable.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
Input/Output Main Memory istream ostream Disk Drive Keyboard Scanner Disk Drive Monitor Printer stream = sequence of bytes.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
C++ programming I Lab#3 Control Statements Instructor: Eng. Ruba A. Salamah Tuseday: 17/10/2010.
Chapter 2 Evaluating an Expression. CIS Evaluating an Expression2-2 Problem (The Registrar's Headache): Student's are to be allowed to register.
Programming is instructing a computer to perform a task for you with the help of a programming language.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
CSC 107 – Programming For Science. Today’s Goal ALL  Understand why ALL I/O is file I/O  Common bugs to avoid when coding with files in C++  Get a.
Input & Output: Console
CHAPTER 3 INPUT/OUTPUT. In this chapter, you will:  Learn what a stream is and examine input and output streams  Explore how to read data from the standard.
Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Current Assignments Homework 3 is due tonight. Iteration and basic functions. Exam 1 on Monday.
Lecture 3: The parts of a C++ program Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
Week 1 Algorithmization and Programming Languages.
C++ Character Set It is set of Characters/digits/symbol which is valid in C++. Example – A-Z, (white space) C++ Character Set It is set of.
CHAPTER 7 DATA INPUT OUTPUT Prepared by: Lec. Ghader R. Kurdi.
TEXT FILES. CIN / COUT REVIEW  We are able to read data from the same line or multiple lines during successive calls.  Remember that the extraction.
3. FORMATTED INPUT/OUTPUT. The printf Function The first argument in a call of printf is a string, which may contain both ordinary characters and conversion.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
Chapter 2: Introduction to C++. Outline Basic “Hello World!!” Variables Data Types Illustration.
String and Character Manipulation.
CHAPTER 2 PART #3 C++ INPUT / OUTPUT 1 st Semester King Saud University College of Applied studies and Community Service CSC1101 By: Fatimah.
String as Arrays, Array Sorting C++ Programming Technologies.
Program Development Cycle 1.Edit program 2.Compile program - translates it from C to machine language 3. Run/execute your program. 4. If not satisfied,
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
CSCI 1100/1202 January 14, Abstraction An abstraction hides (or ignores) the right details at the right time An object is abstract in that we don't.
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program.
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
C++ Basics Lecture 2.
C++ Programming Language Lecture 4 C++ Basics – Part II
Chapter-01 A Sample C++ Program.
Topic Pre-processor cout To output a message.
What Actions Do We Have Part 1
Wel come.
Computing Fundamentals
Command Line Arguments
getline() function with companion ignore()
Chapter 2 part #3 C++ Input / Output
OUTPUT STATEMENTS GC 201.
C++ Basics.
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
Escape Sequences Some Java escape sequences: See Roses.java (page 68)
Counting Loops.
Introduction to Programming - 3
Escape sequences escape sequence: A special sequence of characters used to represent certain special characters in a string. \t Inserts a tab in the.
Nate Brunelle Today: Strings, Type Casting
Java Programming Language
What Actions Do We Have Part 1
Chapter 2 part #3 C++ Input / Output
C++ Programming Language Lecture 4 C++ Basics – Part II
Using string type variables
CS31 Discussion 1D Winter19: week 4
Programming Strings.
Reading from and Writing to Files Part 2
getline() function with companion ignore()
Programming Fundamental-1
Module 2 - Part 1 Variables, Assignment, and Data Types
Presentation transcript:

Odds and Ends

Ternary Operator expression1 ? expression2 : expression3

Ternary Operator expression1 ? expression2 : expression3

Ternary Operator expression1 ? expression2 : expression3

Ternary Operator expression1 ? expression2 : expression3

Example #1 cout << num_pennies << " penn" << (num_pennies == 1 ? "y" : "ies") << endl;

Example #2 int val1, num1, bigger; cout<<“enter two numbers: “; cin>>val1>>num1; bigger = (val1 > num1 ? Val1 : num1); cout<<“the larger of your inputs is “ <<bigger<<endl;

Newlines cout << “hello\n”; cout << “hello” << endl; \n ascii standard for linefeed - output buffered cout << “hello” << endl; endl clears std output buffer

Escape Sequences \r – carriage return; moves cursor to the start of the line \n - newline char; brings cursor to the next line \t - tab character; used to tab output over some spaces \a - alert; rings a bell in your computer \\ - backslash; allows you to output a \ character \’ - allows output of single tick \” - allows output of quotes \0 - NULL char; we’ll work with this later in the semester \b - backspace

End of Session