BITG 1233: Introduction to C++

Size: px
Start display at page:

Download "BITG 1233: Introduction to C++"

Transcription

1 BITG 1233: Introduction to C++ 1

2 Learning Outcomes At the end of this lecture, you should be able to: Identify basic structure of C++ program (pg 3) Describe the concepts of : Character set. (pg 11) Token (pg 13): keyword, identifiers, operator, punctuation, string literal Data type (pg 25) Input function, output function (pg 33) Operator (pg 37) : arithmetic operators & assignment operators Formatting the Output (pg 49) 2 LECTURE 3

3 Basic Structure of a C++ Program /* This program computes the distance between two points. */ comment #include <iostream> // Required for cout, endl. #include <cmath> // Required for sqrt() using namespace std; // Tells which namespace to use comments // Define and initialize global variables. double x1=1, y1=5, x2=4, y2=7; 6 int main() function named main { beginning of block for main // Define local variables. double side1, side2, distance; // Compute sides of a right triangle. side1 = x2 - x1; side2 = y2 - y1; distance = sqrt(side1*side1 + side2*side2); // Print distance. string literal cout << "The distance between the two points is " << distance << endl; // Exit program. return 0; send 0 to operating system } end of block for main 3 LECTURE 3 Figure 3.1 Structure of a C++ Program

4 Structure of a C++ Program : Comments Use to write document parts (notes) of the program. Comments help people read programs: Indicate the purpose of the program Describe the use of variables Explain complex sections of code Are ignored by the compiler. In C++ there are two types of comments. Single-Line comments : Begin with // through to the end of the line. Multi-Line comments : Begin with /* and end with */ 4 LECTURE 3

5 Single-Line Comments Use to write just one line of comment : Example : int length = 12; // length in inches int width = 15; // width in inches int area; // calculated area // calculate rectangle area area = length * width; 5 LECTURE 3

6 Multi-Line Comments Could span multiple lines: /* this is a multi-line comment */ Could begin and end on the same line: int area; /* calculated area */ 6 LECTURE 3

7 Structure of a C++ Program : Preprocessor Directives Provide instructions to the compiler that are performed before the program is translated. Begin with a pound sign (#) Do NOT place a semicolon (;) at the end of a preprocessor directive line. Example: #include <iostream> The #include directive instructs the compiler to include the statements from file iostream into the program. The program needs <iostream> header file because it might need to do input and/or output operations. 7 LECTURE 3

8 Structure of a C++ Program : using Directive Instructs the compiler to use files defined in a specified area. The area is known as namespace. Example : using namespace std; The namespaces of the standard C++ system libraries is std. 8 LECTURE 3

9 Structure of a C++ Program : Function A function s process is defined between a set of braces { }. Example: int main() { //Block defines body of main function double x1 = 1, x2 = 4, side1; side1 = x2 x1; cout << side1 << endl; return 0; //Function main returns 0 to the OS } //end definition of main Every C++ program MUST contains only one function named as main(), and could consist of other function/s. C++ program always begins execution in main(). 9 LECTURE 3

10 Structure of a C++ Program : Global/Local Declarations Area An identifier cannot be used before it is defined. The areas where identifiers in a program are declared determines the scope of the identifiers. The scope of an identifier: the part of the program in which the identifier can be accessed. Local scope - a local identifier is defined or declared in a function or a block, and can be accessed only within the function or block that defines it. Global scope - a global identifier is defined or declared outside the main function, and can be accessed within the program after the identifier is defined or declared. 10 LECTURE 3

11 Character Set Consist of : 1. Number : 0 to 9 2. Alphabet : a to z and A to Z 3. Spacing 4. Special Character :,. : ;?! ( ) {} + - * / = > < # % & ^ ~ / _ 11 LECTURE 3

12 Special Characters Character Name Meaning // Double slash Beginning of a comment # Pound sign Beginning of preprocessor directive < > Open and close brackets Enclose header file name in #include ( ) Open and close parentheses Used when naming a function { } Open and close brace Encloses a group of statements " " Open and close quotation marks Encloses string of characters ; Semicolon End of a programming statement

13 Token Combination of characters, that consist of : 1. Reserved words/keywords 2. Identifiers (variable, constant, function name) 3. Punctuators 4. Operators 5. String Literal 13 LECTURE 3

14 Reserved word/ Keyword A word that has special meaning in C++. Used only for their intended purpose. Keywords cannot be used to name identifiers. All reserves word appear in lowercase. 14

15 Identifiers Allows programmers to name data and other objects in the program : variable, constant, function etc. Can use any capital letter A through Z, lowercase letters a through z, digits 0 through 9 and also underscore ( _ ) Rules for identifier: The first character must be alphabetic character or underscore It must consists only of alphabetic characters, digits and underscores. (cannot contain spaces & special characters except underscore) It cannot duplicate any reserved word C++ is case-sensitive; this means that CASE, Case, case, and CaSe are four completely different words. 15 LECTURE 3

16 Identifiers Valid names Invalid names A student_name _asystemname pi al stdntnm _anthrsysnm PI sum$ // $ is illegal 2names // can t start with 2 stdnt Nmbr // can t have space int // can t use reserved word 16 LECTURE 3

17 Identifiers : Constant Constant is memory location/s that store a specific value that CANNOT be modified during the execution of a program. Types of constant: Integer constant Float constant Numbers with decimal part Character constant A character enclosed between a set of single quotes ( ) String constant A sequence of zero or more characters enclosed in a set of double quotes ( ) 17 LECTURE 3

18 Constant: How to Define How a constant is defined is reflected as Defined constant and Memory constant Defined constant Placed at the preprocessor directive area. Using the preprocessor command define prefaced with the pound sign (#) E.g #define SALES_TAXES_RATE.0825 The expression that follows the name (.0825) replaces the name wherever it is found in the program. Memory constant Placed at global/local declaration area, depending on constant s scope. Add the type qualifier, const before the definition. E.g. const double TAX_RATE = ; 18 const int NUM_STATES = 50; LECTURE 3

19 Constant : How to use Constant can be used in two ways. Literal constant : by writing the value directly in the program. E.g 10 is an integer literal constant 4.5 is a floating point literal constant "Side1" is a string literal constant 'a' is a character literal constant Named constant : by using a name to represent the value in the program. Often the name is written in uppercase letters. 19 LECTURE 3

20 Identifiers : Variables Variable is memory location/s that store values that can be modified. Has a name and a type of data it can hold. Must be defined before it can be used. A variable name should reflect the purpose of the variable. For example: itemsordered The purpose of this variable is to hold the number of items ordered. Once defined, variables are used to hold the data that are required by the program from its operation. Example: double x1=1.0, x2=4.5, side1; side1 = x2-x1; x1, x2 and side1 are examples of variables that can be modified. 20 LECTURE 3

21 Variables Figure 3.4 Variables in memory 21 LECTURE 3

22 Variables Variable declaration syntax : <variable type> <variable name> Examples : short int maxitems; // word separator : capital long int national_debt; // word separator : _ float payrate; // word separator : capital double tax; char code; bool valid; int a, b; Examples of variable definition 22 LECTURE 3

23 Variable initialization Initializer establishes the first value that the variable will contain. To initialize a variable when it is defined, the identifier is followed by the assignment operator (=) and then the initializer which is the value the variable is to have when that part of the program executes. Eg: int count = 0; int count, sum = 0; // Only sum is initialize. int count=0, sum = 0; OR int count =0; int sum = 0; 23 LECTURE 3

24 Punctuator Special character use for completing program structure Includes the symbols [ ] ( ) { }, ; : * # Operator C++ uses a set of built in operators ( Eg : +, -, *, / etc). There are several types of operators : arithmetic, assignment, relational and logical. 24 LECTURE 3

25 Data types Type that defines a set of value and operations that can be applied on those values Set of values for each type is known as the domain for the type Functions also have types which is determined by the data it returns 25 LECTURE 3

26 26 LECTURE 3 Standard Data Type

27 Data types C++ contains five standard data types void int (short for integers) char (short for characters) float ( short for floating points) bool (short for boolean) They serves as the basic structure for derived data types Derived data types are pointer, enumerated type, union, array, structure and class. 27 LECTURE 3

28 Data types void Has no values and operations Both set of values are empty char A value that can be represented by an alphabet, digit or symbol A char is stored in a computer s memory as an integer representing the ASCII code. Usually use 1 byte of memory 28 LECTURE 3

29 Data types int A number without a fraction part (round or integer) C++ supports three different sizes of integer short int int long int 29 LECTURE 3 Typical integer size

30 Data types float A number with fractional part such as C++ supports three types of float float double long double 30 LECTURE 3 Typical float size

31 Data types bool Boolean (logical) data C++ support bool type C++ provides two constant to be used True False Is an integral which is when used with other integral type such as integer values, it converted the values to 1 (true) and 0 (false) 31 LECTURE 3

32 Determining the Size of a Data Type The sizeof operator gives the size of any data type or variable: double amount; cout << "A double is stored in " << sizeof(double) << "bytes\n"; cout << "Variable amount is stored in " << sizeof(amount) << "bytes\n";

33 Input / output function Input function cin cin is used to read input from standard input device (the keyboard) Input retrieved from cin with the extraction operator >> cin, requires iostream header file Input is stored in one or more variables. Data entered from the keyboard must be compatible with the data type of the variable. E.g of program: int age; float a, b; cin >> age; cin >> a >> b; // input must be an integer number // input must be two real numbers 33 LECTURE 3

34 Input / output function Output function - cout cout is defined in the header file iostream, to place data to standard output device (the display) We use the insertion operator << with cout to output string literals, or the value of an expression. String literals contains text of what you want to display. Enclosed in double quote marks ( ). An expression is a C++ constant, identifier, formula, or function call. 34 E.g of program : Assume the age input is 22 and name is Abu. cout << " I am " << age; cout << " years old and my name is "; cout << name; Output : I am 22 years old and my name is Abu

35 Displaying a Prompt A prompt is a message that instructs the user to enter data. You should always use cout to display a prompt before each cin statement. Example: cout << "How tall is the room? "; cin >> height; 35 LECTURE 3

36 Input / output function 36 LECTURE 3 Figure 3.5 Library functions and the linker

37 Arithmetic Operators Assume int a=4, b=5, d; C++ Operation Arithmetic Operator C++ Expression Addition + d = a + b 9 Substraction - d = b Multiplication * d = a * b 20 Division / d = a/2 2 Modulus % d = b%3 2 Value of d after assignment 37 LECTURE 3

38 Assignment Operators Assume int x=4, y=5, z=8; Assignmen t Operator Sample Expression Similar Expression Value of variable after assignment += x += 5 x = x + 5 x=9 -= y -= x y = y - x y=1 *= x *= z x = x*z x=32 /= z /=2 z = z/2 z = 4 %= y %=x y = y%x y=1 38 LECTURE 3

39 Increment and decrement Operators Operator Called Sample Expression Similar Expression Explanation ++ preincrement ++a a = a +1 a += 1 Increment a by 1, then use the new value of a to evaluate the expression in which a reside ++ postincrement a++ a = a +1 a += predecrement - - a a = a -1 a -= postdecrement a - - a = a -1 a -= 1 Use the current value of a to evaluate the expression in which a reside, then increment a by 1 Decrement a by 1, then use the new value of a to evaluate the expression in which a reside Use the current value of a to evaluate the expression in which a reside, then decrement a by 1 For example: assume k=5 prior to executing each of the following statement. m = ++k; both m and k become 6 39 n = k--; n becomes 5, k becomes 4

40 Precedence of Arithmetic and Assignment Operators Precedence Operator Associativity 1 Parentheses: () Innermost first 2 Unary operators Binary operators * / % 4 Binary operators Assignment operators = += -= *= /= %= Right to left Left ot right Left ot right Right to left 40 LECTURE 3

41 A Closer Look at the / Operator / (division) operator performs integer division if both operands are integers cout << 13 / 5; // displays 2 cout << 91 / 7; // displays 13 If either operand is floating point, the result is floating point cout << 13 / 5.0; // displays 2.6 cout << 91.0 / 7; // displays LECTURE 3

42 A Closer Look at the % Operator % (modulus) operator computes the remainder resulting from integer division cout << 13 % 5; // displays 3 % requires integers for both operands cout << 13 % 5.0; // error 42 LECTURE 3

43 Operator Precedence Example 1: int a=10, b=20, c=15, d=8; a * b / (-c * 31 % 13) * d ; 1. a * b / (-15 * 31 % 13) * d 2. a * b / (-465 % 13) * d 3. a * b / (-10) * d / (-10) * d * d Example 2: int a=15, b=6, c=5, d=4; d *= ++b a / 3 + c ; 1. d *= ++b - a / 3 + c 2. d* = 7-15 / 3 + c 3. d* = c 4. d*= d*= 7 6. d = d * 7 7. d = LECTURE 3

44 Example 1 // operating with variables #include <iostream> using namespace std; int main() { int num1, num2; int value_div, value_mod ; } cout << "Enter two integral numbers:"; cin >> num1 >> num2; value_div = num1/num2; value_mod = num1 % num2; cout << num1 << " / " << num2 << " is "<< value_div; cout<<" with a remainder of " << value_mod <<endl; return 0; 44 LECTURE 3 Output : Enter two integral numbers : / 6 is 1 with a remainder of 4

45 Example 2 /*Evaluate two complex expressions*/ LECTURE 3 45 #include <iostream> using namespace std; int main ( ) { int a = 3, b = 4, c = 5, x, y; cout << "Initial values of the variables:\n"; cout << "a = " << a << " b = " << b << "c = " << c <<endl; cout << endl; x = a * 4 + b / 2 - c * b; cout << "Value of a * 4 + b / 2 - c * b is : "<< x <<endl; y = --a * (3 + b) / 2 - c++ * b; cout << "Value of --a * (3 + b) / 2 c++ * b is: "; cout << y << endl << endl; cout << "Values of the variables now are :\n"; cout << "a = " << a << " b = " << b << " c = "<< c <<endl; return 0; }

46 Output : Initial values of the variables : a = 3 b = 4 c = 5 Value of a * 4 + b / 2 - c * b is : -6 Value of --a * (3 + b) / 2 c++ * b is: -13 Values of the variables are now : a = 2 b = 4 c = 6 46

47 Formatting Output We can identify functions to perform special task. For the input and output objects, these functions have been given a special name: manipulator The manipulator functions format output so that it is presented in a more readable fashion for the user. Must include <iomanip> header file. Eg: #include <iomanip> 47 LECTURE 3 <iomanip> header file contains function prototypes for the stream manipulators that enable formatting of streams of data.

48 Output Manipulators The lists of functions in the <iomanip> library file: endl dec oct hex Manipulators fixed showpoint setw( ) setprecision setfill( ) Use New line Formats output as decimal Formats output as octal Formats output as hexadecimal Set floating-point decimals Shows decimal in floating-point values Sets width of output fields Specifies number of decimals for floating point Specifies fill character 48 LECTURE 3

49 Basic Command of Output : Escape Sequence Escape Sequence Name Description \t Horizontal Tab Takes the cursor to the next tab stop \n or endl New line Takes the cursor to the beginning of the next line \v Vertical Tab Takes the cursor to the next tab stop vertically. \" Double Quote Displays a quotation mark (") \' Apostrophe Displays an apostrophe (') \? Question mark Displays a question mark \\ Backslash Displays a backslash (\) \a Audible alert sound 49 LECTURE 3

50 Example: //demonstrate the output manipulator #include <iostream> #include <iomanip> using namespace std; LECTURE 3 int main( ) { char letter; int num; float amount; 50 } cout << "Please enter an integer,"; cout << " a dollar amount and a character.\n"; cin >> num >> amount >> letter; cout <<"\nthank you.you entered:\n"; cout << setw( 6 ) << num << " " ; cout << setfill('*') << setprecision (2) << fixed; cout << "RM" << setw(10) << amount; cout << setfill(' ') << setw( 3 ) << letter << endl; return 0;

51 Output : Please enter an integer,a dollar amount and character G Thank you. You entered: 12 RM**** G --- THE END LECTURE 3

LECTURE 02 INTRODUCTION TO C++

LECTURE 02 INTRODUCTION TO C++ PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 02 INTRODUCTION

More information

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley

More information

Chapter 2: Introduction to C++

Chapter 2: Introduction to C++ Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++

More information

The C++ Language. Arizona State University 1

The C++ Language. Arizona State University 1 The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

CHAPTER 3 BASIC INSTRUCTION OF C++

CHAPTER 3 BASIC INSTRUCTION OF C++ CHAPTER 3 BASIC INSTRUCTION OF C++ MOHD HATTA BIN HJ MOHAMED ALI Computer programming (BFC 20802) Subtopics 2 Parts of a C++ Program Classes and Objects The #include Directive Variables and Literals Identifiers

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine

More information

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018 C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing

More information

Objectives. In this chapter, you will:

Objectives. In this chapter, you will: Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about

More information

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this

More information

Engineering Problem Solving with C++, Etter/Ingber

Engineering Problem Solving with C++, Etter/Ingber Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs C++, Second Edition, J. Ingber 1 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input

More information

Getting started with C++ (Part 2)

Getting started with C++ (Part 2) Getting started with C++ (Part 2) CS427: Elements of Software Engineering Lecture 2.2 11am, 16 Jan 2012 CS427 Getting started with C++ (Part 2) 1/22 Outline 1 Recall from last week... 2 Recall: Output

More information

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols. EEE-117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic

More information

A First Program - Greeting.cpp

A First Program - Greeting.cpp C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

PART I.   Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++. Unit - III CHAPTER - 9 INTRODUCTION TO C++ Choose the correct answer. PART I 1. Who developed C++? (a) Charles Babbage (b) Bjarne Stroustrup (c) Bill Gates (d) Sundar Pichai 2. What was the original name

More information

Creating a C++ Program

Creating a C++ Program Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an

More information

Chapter Two MULTIPLE CHOICE

Chapter Two MULTIPLE CHOICE Chapter Two MULTIPLE CHOICE 1. In a C++ program, two slash marks ( // ) indicate: a. The end of a statement b. The beginning of a comment c. The end of the program d. The beginning of a block of code 2.

More information

Introduction to Programming

Introduction to Programming Introduction to Programming session 5 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2010 These slides are created using Deitel s slides Sahrif University of Technology Outlines

More information

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program 1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize

More information

Engineering Problem Solving with C++, 3e Chapter 2 Test Bank

Engineering Problem Solving with C++, 3e Chapter 2 Test Bank 1. Match each of the following data types with literal constants of that data type. A data type can be used more than once. A. integer B 1.427E3 B. double D "Oct" C. character B -63.29 D. string F #Hashtag

More information

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1

ADARSH VIDYA KENDRA NAGERCOIL COMPUTER SCIENCE. Grade: IX C++ PROGRAMMING. Department of Computer Science 1 NAGERCOIL COMPUTER SCIENCE Grade: IX C++ PROGRAMMING 1 C++ 1. Object Oriented Programming OOP is Object Oriented Programming. It was developed to overcome the flaws of the procedural approach to programming.

More information

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?

Intro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program? Intro to Programming & C++ Unit 1 Sections 1.1-4 and 2.1-10, 2.12-13, 2.15-17 CS 1428 Spring 2019 Jill Seaman 1.1 Why Program? Computer programmable machine designed to follow instructions Program a set

More information

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char Week 1 Operators, Data Types & I/O Gaddis: Chapters 1, 2, 3 CS 5301 Fall 2016 Jill Seaman Programming A program is a set of instructions that the computer follows to perform a task It must be translated

More information

Chapter 1 Introduction to Computers and C++ Programming

Chapter 1 Introduction to Computers and C++ Programming Chapter 1 Introduction to Computers and C++ Programming 1 Outline 1.1 Introduction 1.2 What is a Computer? 1.3 Computer Organization 1.7 History of C and C++ 1.14 Basics of a Typical C++ Environment 1.20

More information

c++ keywords: ( all lowercase ) Note: cin and cout are NOT keywords.

c++ keywords: ( all lowercase ) Note: cin and cout are NOT keywords. Chapter 1 File Extensions: Source code (cpp), Object code (obj), and Executable code (exe). Preprocessor processes directives and produces modified source Compiler takes modified source and produces object

More information

Chapter 2. Outline. Simple C++ Programs

Chapter 2. Outline. Simple C++ Programs Chapter 2 Simple C++ Programs Outline Objectives 1. Building C++ Solutions with IDEs: Dev-cpp, Xcode 2. C++ Program Structure 3. Constant and Variables 4. C++ Operators 5. Standard Input and Output 6.

More information

Computer Programming : C++

Computer Programming : C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program

More information

BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

More information

REVIEW. The C++ Programming Language. CS 151 Review #2

REVIEW. The C++ Programming Language. CS 151 Review #2 REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

Lecture 2 Tao Wang 1

Lecture 2 Tao Wang 1 Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors

More information

2 nd Week Lecture Notes

2 nd Week Lecture Notes 2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

1. Match each of the following data types with literal constants of that data type. A data type can be used more than once. A.

1. Match each of the following data types with literal constants of that data type. A data type can be used more than once. A. Engineering Problem Solving With C++ 4th Edition Etter TEST BANK Full clear download (no error formating) at: https://testbankreal.com/download/engineering-problem-solving-with-c-4thedition-etter-test-bank/

More information

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja

More information

Fundamentals of Programming CS-110. Lecture 2

Fundamentals of Programming CS-110. Lecture 2 Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout

More information

Chapter 2 - Introduction to C Programming

Chapter 2 - Introduction to C Programming Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

Lecture 3 Tao Wang 1

Lecture 3 Tao Wang 1 Lecture 3 Tao Wang 1 Objectives In this chapter, you will learn about: Arithmetic operations Variables and declaration statements Program input using the cin object Common programming errors C++ for Engineers

More information

Chapter 2: Overview of C++

Chapter 2: Overview of C++ Chapter 2: Overview of C++ Problem Solving, Abstraction, and Design using C++ 6e by Frank L. Friedman and Elliot B. Koffman C++ Background Introduced by Bjarne Stroustrup of AT&T s Bell Laboratories in

More information

! A literal represents a constant value used in a. ! Numbers: 0, 34, , -1.8e12, etc. ! Characters: 'A', 'z', '!', '5', etc.

! A literal represents a constant value used in a. ! Numbers: 0, 34, , -1.8e12, etc. ! Characters: 'A', 'z', '!', '5', etc. Week 1: Introduction to C++ Gaddis: Chapter 2 (excluding 2.1, 2.11, 2.14) CS 1428 Fall 2014 Jill Seaman Literals A literal represents a constant value used in a program statement. Numbers: 0, 34, 3.14159,

More information

Introduction to Programming EC-105. Lecture 2

Introduction to Programming EC-105. Lecture 2 Introduction to Programming EC-105 Lecture 2 Input and Output A data stream is a sequence of data - Typically in the form of characters or numbers An input stream is data for the program to use - Typically

More information

Programming. C++ Basics

Programming. C++ Basics Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++

More information

CSc 10200! Introduction to Computing. Lecture 4-5 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 4-5 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 4-5 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 3 Assignment, Formatting, and Interactive Input

More information

Lab # 02. Basic Elements of C++ _ Part1

Lab # 02. Basic Elements of C++ _ Part1 Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING Dr. Shady Yehia Elmashad Outline 1. Introduction to C++ Programming 2. Comment 3. Variables and Constants 4. Basic C++ Data Types 5. Simple Program: Printing

More information

CS242 COMPUTER PROGRAMMING

CS242 COMPUTER PROGRAMMING CS242 COMPUTER PROGRAMMING I.Safa a Alawneh Variables Outline 2 Data Type C++ Built-in Data Types o o o o bool Data Type char Data Type int Data Type Floating-Point Data Types Variable Declaration Initializing

More information

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3

Programming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3 Programming - 1 Computer Science Department 011COMP-3 لغة البرمجة 1 011 عال- 3 لطالب كلية الحاسب اآللي ونظم المعلومات 1 1.1 Machine Language A computer programming language which has binary instructions

More information

Differentiate Between Keywords and Identifiers

Differentiate Between Keywords and Identifiers History of C? Why we use C programming language Martin Richards developed a high-level computer language called BCPL in the year 1967. The intention was to develop a language for writing an operating system(os)

More information

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics 1 Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-3 2.1 Variables and Assignments 2

More information

UNIT-2 Introduction to C++

UNIT-2 Introduction to C++ UNIT-2 Introduction to C++ C++ CHARACTER SET Character set is asset of valid characters that a language can recognize. A character can represents any letter, digit, or any other sign. Following are some

More information

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh C++ PROGRAMMING For Industrial And Electrical Engineering Instructor: Ruba A. Salamh CHAPTER TWO: Fundamental Data Types Chapter Goals In this chapter, you will learn how to work with numbers and text,

More information

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

Introduction to C Programming. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Introduction to C Programming Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Outline Printing texts Adding 2 integers Comparing 2 integers C.E.,

More information

CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++

CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++ CS101: Fundamentals of Computer Programming Dr. Tejada stejada@usc.edu www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++ 10 Stacks of Coins You have 10 stacks with 10 coins each that look and feel

More information

Chapter 2. Lexical Elements & Operators

Chapter 2. Lexical Elements & Operators Chapter 2. Lexical Elements & Operators Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr The C System

More information

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program Overview - General Data Types - Categories of Words - The Three S s - Define Before Use - End of Statement - My First Program a description of data, defining a set of valid values and operations List of

More information

Basics of Java Programming

Basics of Java Programming Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement

More information

CSc Introduction to Computing

CSc Introduction to Computing CSc 10200 Introduction to Computing Lecture 2 Edgardo Molina Fall 2011 - City College of New York Thursday, September 1, 2011 Introduction to C++ Modular program: A program consisting of interrelated segments

More information

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style 3 2.1 Variables and Assignments Variables and

More information

Chapter 2. C++ Basics

Chapter 2. C++ Basics Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-2 2.1 Variables and Assignments Variables

More information

EEE145 Computer Programming

EEE145 Computer Programming EEE145 Computer Programming Content of Topic 2 Extracted from cpp.gantep.edu.tr Topic 2 Dr. Ahmet BİNGÜL Department of Engineering Physics University of Gaziantep Modifications by Dr. Andrew BEDDALL Department

More information

CHAPTER 3 Expressions, Functions, Output

CHAPTER 3 Expressions, Functions, Output CHAPTER 3 Expressions, Functions, Output More Data Types: Integral Number Types short, long, int (all represent integer values with no fractional part). Computer Representation of integer numbers - Number

More information

Reserved Words and Identifiers

Reserved Words and Identifiers 1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the

More information

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

ME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types

ME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types ME240 Computation for Mechanical Engineering Lecture 4 C++ Data Types Introduction In this lecture we will learn some fundamental elements of C++: Introduction Data Types Identifiers Variables Constants

More information

Introduction to the C++ Programming Language

Introduction to the C++ Programming Language LESSON SET 2 Introduction to the C++ Programming Language OBJECTIVES FOR STUDENT Lesson 2A: 1. To learn the basic components of a C++ program 2. To gain a basic knowledge of how memory is used in programming

More information

C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal

C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal TOKENS C++ character set Letters:- A-Z, a-z Digits:- 0 to 9 Special Symbols:- space + - / ( ) [ ] =! = < >, $ # ; :? & White Spaces:- Blank Space, Horizontal Tab, Vertical tab, Carriage Return. Other Characters:-

More information

CSCE 110 PROGRAMMING FUNDAMENTALS

CSCE 110 PROGRAMMING FUNDAMENTALS CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 2. Overview of C++ Prof. Amr Goneid, AUC 1 Overview of C++ Prof. Amr Goneid, AUC 2 Overview of C++ Historical C++ Basics Some Library

More information

Fundamentals of Programming. Lecture 3: Introduction to C Programming

Fundamentals of Programming. Lecture 3: Introduction to C Programming Fundamentals of Programming Lecture 3: Introduction to C Programming Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department Outline A Simple C

More information

Introduction to C++ Programming. Adhi Harmoko S, M.Komp

Introduction to C++ Programming. Adhi Harmoko S, M.Komp Introduction to C++ Programming Adhi Harmoko S, M.Komp Machine Languages, Assembly Languages, and High-level Languages Three types of programming languages Machine languages Strings of numbers giving machine

More information

WARM UP LESSONS BARE BASICS

WARM UP LESSONS BARE BASICS WARM UP LESSONS BARE BASICS CONTENTS Common primitive data types for variables... 2 About standard input / output... 2 More on standard output in C standard... 3 Practice Exercise... 6 About Math Expressions

More information

Guide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below:

Guide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below: Q1. Explain the structure of a C program Structure of the C program is shown below: Preprocessor Directives Global Declarations Int main (void) Local Declarations Statements Other functions as required

More information

Maciej Sobieraj. Lecture 1

Maciej Sobieraj. Lecture 1 Maciej Sobieraj Lecture 1 Outline 1. Introduction to computer programming 2. Advanced flow control and data aggregates Your first program First we need to define our expectations for the program. They

More information

Operations. Making Things Happen

Operations. Making Things Happen Operations Making Things Happen Object Review and Continue Lecture 1 2 Object Categories There are three kinds of objects: Literals: unnamed objects having a value (0, -3, 2.5, 2.998e8, 'A', "Hello\n",...)

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

More information

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++ CSCE 206: Structured Programming in C++ 2017 Spring Exam 1 Monday, February 13, 2017 Total - 100 Points B Instructions: Total of 11 pages, including this cover and the last page. Before starting the exam,

More information

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++ CSCE 206: Structured Programming in C++ 2017 Spring Exam 1 Monday, February 13, 2017 Total - 100 Points A Instructions: Total of 11 pages, including this cover and the last page. Before starting the exam,

More information

Chapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments

Chapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Copyright 2011 Pearson Addison-Wesley. All rights

More information

VARIABLES & ASSIGNMENTS

VARIABLES & ASSIGNMENTS Fall 2018 CS150 - Intro to CS I 1 VARIABLES & ASSIGNMENTS Sections 2.1, 2.2, 2.3, 2.4 Fall 2018 CS150 - Intro to CS I 2 Variables Named storage location for holding data named piece of memory You need

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

3.1. Chapter 3: The cin Object. Expressions and Interactivity

3.1. Chapter 3: The cin Object. Expressions and Interactivity Chapter 3: Expressions and Interactivity 3.1 The cin Object Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 3-1 The cin Object Standard input stream object, normally the keyboard,

More information

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering Lecture 3 Winter 2011/12 Oct 25 Visual C++: Problems and Solutions New section on web page (scroll down)

More information

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance. 2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

Lecture 4 Tao Wang 1

Lecture 4 Tao Wang 1 Lecture 4 Tao Wang 1 Objectives In this chapter, you will learn about: Assignment operations Formatting numbers for program output Using mathematical library functions Symbolic constants Common programming

More information

1.1 Introduction to C Language. Department of CSE

1.1 Introduction to C Language. Department of CSE 1.1 Introduction to C Language 1 Department of CSE Objectives To understand the structure of a C-Language Program To write a minimal C program To introduce the include preprocessor command To be able to

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables

More information

Full file at C How to Program, 6/e Multiple Choice Test Bank

Full file at   C How to Program, 6/e Multiple Choice Test Bank 2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)

More information

Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School

Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions Mr. Dave Clausen La Cañada High School Vocabulary Variable- A variable holds data that can change while the program

More information

CS102: Variables and Expressions

CS102: Variables and Expressions CS102: Variables and Expressions The topic of variables is one of the most important in C or any other high-level programming language. We will start with a simple example: int x; printf("the value of

More information

CS 151 Review #3. // More than one variable can be defined // in a statement. Multiple variables are // separated by a comma.

CS 151 Review #3. // More than one variable can be defined // in a statement. Multiple variables are // separated by a comma. REVIEW cout Statement The cout statement invokes an output stream, which is a sequence of characters to be displayed to the screen. cout

More information

Introduction to C# Applications

Introduction to C# Applications 1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making

More information