Chapter 2

Size: px
Start display at page:

Download "Chapter 2"

Transcription

1 Chapter 2

2 Topic Contents The IO Stream class C++ Comments C++ Keywords Variable Declaration The const Qualifier The endl, setw, setprecision, manipulators The scope resolution operator The new & delete operator OOPS with C++ Sahaj Computer Solutions 2

3 What is C++? C++ is an object oriented programming language. It was developed by BjarneStroupstrup at AT&T Bell Laboratories in Murray Hills, New Jersey USA in 1979 Initially it was called as C with Classes However later in 1983, the name was changed to C++. The idea of C++ comes from the C increment operator ++, thereby suggesting that C++ is augmented (incremented) version of C. OOPS with C++ Sahaj Computer Solutions 3

4 What is C++? C++ is superset of C. Most of what we already know about C applies to C++ also. C++ C Inheriatance Classes Function &Operator Overloading OOPS with C++ Sahaj Computer Solutions 4

5 Applications of C++ C++ allows us to create a hierarchical related objects, and object libraries. C++ will map the real world problem properly as well as it has the ability to get close to C part of middle level details. C++ programs are easily maintainable and expandable. It is expected that C++ will replace C as a general purpose language in the near future. OOPS with C++ Sahaj Computer Solutions 5

6 Comments C++ introduces a new comment symbol // (double slash). Comments start with double slash symbol and terminate at the end of the line. The comment may start anywhere in the line and whatever follows till the end of line is ignored. Note that there is no closing symbol The // comments is basically a single line comment The C comment symbol (/* */) is still valid and are known as multi line comments. OOPS with C++ Sahaj Computer Solutions 6

7 Comments Single Line Comments // This is an example of // C++ Program to illustrate // Comments Multi Line Comments /* This is an example of C++ program to demonstrate Multiline Comments */ OOPS with C++ Sahaj Computer Solutions 7

8 Keywords The keywords implement specific C++ language features and cannot be explicitly used as names for the program variables, functions, classes, structures or functions. Following are the keywords used in C++ asm auto break case catch operator private char class const continue default protected public delete do double else enum register return extern float for friend goto short signed if inline int long new sizeof static struct switch template this throw try typedef OOPS with C++ Sahaj Computer Solutions 8

9 Keywords union unsigned virtual void volatile while Added by Ansi C++ bool const_cast dynamic_cast explicit Export false mutable namespace reinterpret_c ast static_cast true typeid typename using wchar_t OOPS with C++ Sahaj Computer Solutions 9

10 Identifiers and Constants Identifiers refer to the name of variables, functions, arrays, classes, etc created by the programmers. Rules: Only alphabetic characters, digits and underscore are permitted The name cannot start with a digit. Uppercase and Lowercase letters are distinct Keywords cannot be used as variable name. Constants refer to fixed values that do not change during the execution of a program. OOPS with C++ Sahaj Computer Solutions 10

11 Program structure C++ program would contain four sections. The class declarations contains class definition with function declaration Member function definitions contains the definition of functions with a scope resolution operator which represents its class. Main Function is the start point of any c++ program Header Files Class Declaration Member Function definitions Main Function Program OOPS with C++ Sahaj Computer Solutions 11

12 First C++ Program // A simple C++ Program #include<iostream.h> intmain() { cout<< C++ is better than C.\n ; // C++ statement return 0; } //end of program OOPS with C++ Sahaj Computer Solutions 12

13 The iostreamfile # include<iostream.h> This directive causes the preprocessor to ass the contents of iostream file to the program. It contains declarations for cout and the operator <<. It should be included at the beginning of all programs that use input/output. OOPS with C++ Sahaj Computer Solutions 13

14 Output Operator C++ introduces two new features coutand <<. The identifier cout(pronounced as C out) is a predefined object that represents the standard output stream in c++. Here the standard output stream represents the screen. The couthas a simple interface. If string represents a string variable, then the following statement will display its content. cout<< string; OOPS with C++ Sahaj Computer Solutions 14

15 Output Operator The operator << represents the bitwise left shift operator and is known as Insertion operator. Example: cout<< This is my first c++ program ; Will display the string This is my first c++ program on the standard output device (screen). C++ << This is my first c++ program Object Insertion Operator Variable OOPS with C++ Sahaj Computer Solutions 15

16 Return type of main() In C++ main() returns an integral type value to the operating system. Therefore every main() in C++ should end with a return(0) statement; otherwise the compiler will throw and warning. The default return type of main function is int. OOPS with C++ Sahaj Computer Solutions 16

17 Input Operator The statement cin>>number1; is an input statement and causes the program to wait for the users to type in a number. The number keyed is placed in the variable number1. The operator >> is known as extraction or get from operator. It extracts the value from the keyboard and assigns it to the variable to the right Object Extraction Operator Variable cin 45.5 >> OOPS with C++ Sahaj Computer Solutions 17

18 Basic Data Types C++ Data Types User Defined type Structure Union Class enumeration Built-in type Derived type Array Function Pointer reference Integral type void Floating type int char float double OOPS with C++ Sahaj Computer Solutions 18

19 Datatypes Type Bytes Range char to 127 unsigned char 1 0 to 255 signed char to 127 int to unsigned int to signed int 2 0 to short int to unsigned short int 2 0 to signed short int to long int to signed long int to float 4 0 to double 8 1.7E-38 to 1.7E+308 long double to 1.1E+4932 OOPS with C++ Sahaj Computer Solutions 19

20 Another C++ Program #include<iostream.h> intmain() { int number1,number2,sum; float average; cout<< Enter two numbers <<endl; cin>>number1>>number2; sum=number1+number; average=sum/2; cout<< Average: <<average; return(0); } OOPS with C++ Sahaj Computer Solutions 20

21 User defined Data Types Structures and Classes C has user defined data types such as structand union These data types are legal in C++ and some more new features have been added to make them suitable for the object orientation programming C++ permits another user-defined data type known as class which can be used, just like any other basic data type, to declare variables. The class variables are known as objects, which are central focus of object orientated programming OOPS with C++ Sahaj Computer Solutions 21

22 Enumerated Data Type An enumerated data type is another user-defined data type which provides a way for attaching names to numbers. In other words enumeration data type is used for creating symbolic constants. The enumkeywords automatically enumerates a list of words by assigning them values 0,1,2,3 and so on. Example: enum shape{circle,square,triangle}; enum color{red,blue, green,yellow}; OOPS with C++ Sahaj Computer Solutions 22

23 Enumerated data type In C++ the tag name shape, color becomes new type names. By using the tag names we can declare variables. Example: shape ellipse; //ellipse is of type shape By default enumerators are assigned integer vales starting with 0 for the first enumerator, 1 for the second enumerator and so on. We can override the default values by explicitly assigning integers to enumerators OOPS with C++ Sahaj Computer Solutions 23

24 Enumerated data type Example: enum color{red,blue=6,green=9}; enum color{red=5,blue,green} In the first case, red is 0 by default, blue is 6 and green is 9. OOPS with C++ Sahaj Computer Solutions 24

25 Example Program enum shape { circle, rectangle, triangle }; void main() { cout<< Enter shape code: ; int code; cin>> code; while(code>=circle && code<=triangle) { switch(code) case circle: cout<< Shape is Circle <<endl; break; case rectangle: cout<< Shape is Rectangle << endl; break; case triangle: cout<< Shape is Triangle <<endl; break; default: cout<< Invalid Code <<endl; break; } break; } OOPS with C++ Sahaj Computer Solutions 25

26 Declaration of Variables We know that in C, all the variable s must be declared before they are used. This is true with C++ as well. However there is a significant difference in C++ with regard to place of declaration in the program. C requires all the variables to be defined at the beginning of the program. Before using the variable we need to go the beginning of the program to see whether it has been declared and if so, of what type OOPS with C++ Sahaj Computer Solutions 26

27 Declaration of Variables C++ allows us to declare a variable anywhere in the scope. This means that the variable can be declared right at the place of its first use. This makes programs easier to write and reduces errors that may be caused by having to scan back and forth. It also makes program easier to understand because the variables are declared in the context of their first use. Program : ch2pg4.cpp OOPS with C++ Sahaj Computer Solutions 27

28 Reference Variables C++ introduces a new kind of variable known as the reference variable. A reference variable provides an alias (alternative name ) for the previously defined variable For example, if we make the variable sum a reference to the variable total then sum and total can be used interchangeably to represent that variable. A reference variable can be created as follows: data-type & reference-name = variable-name Examples float total=100; float & sum =total; OOPS with C++ Sahaj Computer Solutions 28

29 Reference Variables Both the variables now refer to the same data object in the memory. Now the statement cout<<total; And cout<<sum; Both prints the value 100. A reference variable must be initialized at the time of declaration. OOPS with C++ Sahaj Computer Solutions 29

30 Operators in C++ C++ Operators Unary Operators Binary Operators TernaryOperators Increment Op ++ Decrement Op -- Conditional Operator? : Arithmetic Operators Relational Operators Bitwise Operators Boolean Operators OOPS with C++ Sahaj Computer Solutions 30

31 Operators in C++ Arithmetic Operators Operator Operation Syntax Example + Addition Result=op1+op2 Sum=5+6 _ Subtraction Result=op1-op2 Diff=a-3 * Multiplication Result=op1*op2 Mul=5*2 / Division Result=op1/op2 Div=sum/2 % Modulo Division Result=op1%op2 Rem=n%2 Program ch2pg7.cpp OOPS with C++ Sahaj Computer Solutions 31

32 Relational Operators In the term relational operator, relational refers to the relationships that values can have with one another. Some of the C++ relational operators are Operator Operation Syntax Example < Less than Op1<Op2 If(9<2) result=9; > Greater than Op1>Op2 If(a>1) result= a is large <= Less than or equal Op1<=Op2 If(a<=b) result=b; >= Greater than or equal Op1>=Op2 If(z>=y) z++; == Equal Op1==Op2 If(num1==num2) s=0;!= Not equal Op1!=Op2 If(a!=b)cout<< not equal ; OOPS with C++ Sahaj Computer Solutions 32

33 Logical Operators Logical operator provides a way of connecting two or more expressions. Operators Actions Syntax && AND Expr1&& Expr2 OR Expr1 Expr2! NOT! Expr OOPS with C++ Sahaj Computer Solutions 33

34 Logical Operators TRUTH TABLE P Q P &&Q P Q!P Program: ch2pg8.cpp OOPS with C++ Sahaj Computer Solutions 34

35 Bitwise Operators Bitwise operation refers to testing, setting, or shifting the actual bits in a byte or word, which correspond to the char andintdatatypes and variants. You cannot use bitwise operations on float, double, long double, void, bool, or other, more complex types. Bitwise operations are applied to the individual bits of the operands. OOPS with C++ Sahaj Computer Solutions 35

36 Bitwise Operators Operator Action & AND OR ^ Exclusive OR (XOR) ~ One s Compliment(NOT) << Right Shift >> Left Shift Program: ch2pg10.cpp OOPS with C++ Sahaj Computer Solutions 36

37 Bitwise Operators The bit-shift operators, >> and <<, move all bits in a variable to the right or left as specified. The general form of the shift-right statement is variable >> number of bit positions The general form of the shift-left statement is variable << number of bit positions As bits are shifted off one end, 0's are brought in the other end. Program: ch2pg9.cpp OOPS with C++ Sahaj Computer Solutions 37

38 Conditional Operator The ternary operator? takes the general form Exp1? Exp2 : Exp3; where Exp1, Exp2, and Exp3 are expressions. The? operator works like this: Exp1 is evaluated. If it is true, Exp2 is evaluated and becomes the value of the expression. If Exp1 is false, Exp3 is evaluated and its value becomes the value of the expression. For example, in x = 10; y = x>9? 100 : 200; y is assigned the value 100. OOPS with C++ Sahaj Computer Solutions 38

39 Increment and Decrement C++ includes two useful operators not generally found in other computer languages. These are the increment and decrement operators, ++ and. The operator ++ adds 1 to its operand, and subtracts one. In other words: x = x+1; is the same as ++x; And x = x-1; is the same as x--; OOPS with C++ Sahaj Computer Solutions 39

40 Increment and Decrement Both the increment and decrement operators may either precede (prefix) or follow (postfix) the operand. For example, x = x+1; can be written or ++x; x++; Program : ch2pg11.cpp OOPS with C++ Sahaj Computer Solutions 40

41 Control Structures The general form of the if statement is if (expression) statement; else statement; Example: if(age<=18) cout<< Not Eligible to Vote else cout<< Eligible to Vote ; Program : CH2PG12.cpp OOPS with C++ Sahaj Computer Solutions 41

42 Control Structures Nested ifs : if inside another if is called nested if Syntax: if(expression) { } else if(expression2) statement1; else statement2 statement3; Program :CH2PG3.CPP OOPS with C++ Sahaj Computer Solutions 42

43 Switch Statement A switch statement is a multi branching statement where, based on a condition, the control is transferred to one of many possible points. Syntax: switch(expression) { case 1: action; case 2: action; : default: action; }; OOPS with C++ Sahaj Computer Solutions 43

44 Switch Statement There are three important things to know about the switch statement: Theswitchdiffersfromtheif inthatswitchcanonlytest for equality, whereas if can evaluate any type of relational or logical expression. No two case constants in the same switch can have identical values. Of course, a switch statement enclosed by an outer switch may have case constants that are the same. If character constants are used in the switch statement, they are automatically converted to integers. OOPS with C++ Sahaj Computer Solutions 44

45 Switch Case Example switch(i) { case 1: /* These cases have common */ case 2: /* statement sequences. */ case 3: flag = 0; break; case 4: flag = 1; case 5: error(flag); break; default: process(i); } OOPS with C++ Sahaj Computer Solutions 45

46 Iteration Statements In C/C++, and all other modern programming languages, iteration statements (also called loops) allow a set of instructions to be executed repeatedly until a certain condition is reached. This condition may be predefined (as in the for loop), or open-ended (as in the while and do-while loops). OOPS with C++ Sahaj Computer Solutions 46

47 The for Loop The general form of the for statement is: for(initialization; condition; increment) { statement; } Example: for(x=1; x <= 100; x++) cout<< x; Program : CH2PG14.CPP OOPS with C++ Sahaj Computer Solutions 47

48 The while Loop Its general form is while(condition) statement; where statementis either an empty statement, a single statement, or a block of statements. The conditionmay be any expression, and true is any nonzero value. The loop iterates while the condition is true. When the condition becomes false, program control passes to the line of code immediately following the loop. OOPS with C++ Sahaj Computer Solutions 48

49 The While Loop Example: while(ch!= 'A') ch = getchar(); return ch; Program: CH2PG15.CPP OOPS with C++ Sahaj Computer Solutions 49

50 The do-while Loop Unlike for and while loops, which test the loop condition at the top of the loop, the do-while loop checks its condition at the bottom of the loop. This means that a do-while loop always executes at least once. The general form of the do-while loop is do{ statement; } while(condition); OOPS with C++ Sahaj Computer Solutions 50

51 The do-while Loop Example: do { scanf("%d", &num); } while(num > 100); Program: CH2PG16.cpp OOPS with C++ Sahaj Computer Solutions 51

52 Jump Statements C/C++ has four statements that perform an unconditional branch: return, goto, break, and continue. Of these, you may use return and gotoanywhere in your program. Youmay use the break and continue statements in conjunction with any of the loop statements. OOPS with C++ Sahaj Computer Solutions 52

53 The return Statement The return statement is used to return from a function. It is categorized as a jump statement because it causes execution to return (jump back) to the point at which the call to the function was made. A return may or may not have a value associated with it. The general form of the return statement is return expression; OOPS with C++ Sahaj Computer Solutions 53

54 The gotostatement The general form of the gotostatement is goto label;... label: where label is any valid label either before or after goto. OOPS with C++ Sahaj Computer Solutions 54

55 The gotostatement For Example: x = 1; loop1: x++; if(x<100) goto loop1; OOPS with C++ Sahaj Computer Solutions 55

56 The break Statement The break statement has two uses. You can use it to terminate a case in the switch statement. You can also use it to force immediate termination of a loop, bypassing the normal loop conditional test. When the break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop. Program: CH2PG16.CPP OOPS with C++ Sahaj Computer Solutions 56

57 The continue Statement The continue statement works somewhat like the break statement. Instead of forcing termination, however, continue forces the next iteration of the loop to take place, skipping any code in between. Program: CH2PG17.CPP OOPS with C++ Sahaj Computer Solutions 57

58 Arrays An array is a collection of variables of the same type that are referred to through a common name. A specific element in an array is accessed by an index. The general form for declaring a array is Example: double balance[100]; type var_name[size]; Program : CH2PG18.cpp OOPS with C++ Sahaj Computer Solutions 58

59 Pointers Program: CH2PG19.cpp A pointer is a variable that holds a memory address. This address is the location of another object (typically another variable) in memory. For example, if one variable contains the address of another variable, the first variable is said to point to the second. The general form for declaring a pointer variable is type *name; where type is the base type of the pointer and may be any valid type. The name of the pointer variable is specified by name. OOPS with C++ Sahaj Computer Solutions 59

60 Const Qualifier The const modifier is used for creating symbolic constant in C++. Any value declared as const cannot be modified by the program in any way. In C++ we can use const in a constant expression such as const int size=10; char name[size]; As with long and short if we use the const modifier alone, it defaults to int. For example const size =10 ; means const int size=10; OOPS with C++ Sahaj Computer Solutions 60

61 Manipulators Manipulators are operators that are used to format the data display. The most commonly used manipulators are endland setw. The endl manipulator, when used in an output statement causes a line feed to be inserted. It has same effect as using the new line character \n. Example: cout<<endl; OOPS with C++ Sahaj Computer Solutions 61

62 Manipulator setw(w) : Set the field width to w. For example: cout<<setw(5)<<sum<<endl; setprecision() : Set the number of digits of precision. For example: cout<<setprecision(6)<<num; setfill(intch) : Set the fill character to ch. Example: cout<<setfill( * ); flush : Flush a stream. To access manipulators that take parameters (such as setw() ), you must include <iomanip> in your program. OOPS with C++ Sahaj Computer Solutions 62

63 Scope Resolution Operator C++ is also block structured language, this means blocks and scope can be used in constructing programs. A scope of the variable extends from the point of its declaration till the end of the block containing the declaration. A variable declared inside that block is said to be local to that block. Consider the following example: OOPS with C++ Sahaj Computer Solutions 63

64 Scope Resolution :::::::::::::::::::::::: { int x=100; ::::::::::::::::::::::::::: } :::::::::::::::::::::: { int x=1; :::::::::::::::::::::::::::::; } The two declarations of x refers to 2 different memory locations containing different values. Statements in second block cannot refer to the variable x declared in first block and vice versa. Blocks in C++ are often nested. OOPS with C++ Sahaj Computer Solutions 64

65 Scope Resolution ::::::::::::::::::::: {// Block 1 int x=10; :::::::::::::::::::: { //Block 2 int x=1; :::::::::::: } :::::::::::::::::::::::::::::: } Block2 is contained in block1. The declaration in inner block hides a declaration of the same variable in an outer block and therefore each declaration of x causes it to refer to a different data object. OOPS with C++ Sahaj Computer Solutions 65

66 Scope Resolution Operator The global version of variable cannot be accessed from within the inner block. C++ resolves this problem by introducing a new operator :: called scope resolution operator. This can be used to uncover a hidden variable. It takes the following form: :: variable-name; For Example: cout<<::m Program: CH2PG21.cpp OOPS with C++ Sahaj Computer Solutions 66

67 Memory Management Operators C++ has two unary operators new and delete that perform the task of allocating and freeing the memory better and easier way. The new operator can be used to create objects of any type. It takes the following general form: pointer-variable =new data-type; When the data is no longer needed, it is destroyed to release the memory space for reuse. The general form of its use is: delete pointer-variable; OOPS with C++ Sahaj Computer Solutions 67

68 SahajComputer Solutions Near Gomatesh School, Hindwadi Belgaum-11, Phone no: , Get Certified in Microsoft Office 2010 Tally 9.2.NET 2008 J2EE CORE JAVA C PROGRAMMING OOPS WITH C++ JOOMLA WORDPRESS PHP AND MYSQL SQLSERVER UNIX AND LINUX ANDRIOD APPS Around 1800 students developed software projects and scored the top scores in exams. One stop shop for Software Projects Website Development Technology Training I.T Research Visit: OOPS with C++ Sahaj Computer Solutions 68

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming

More information

Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

Introduction to Programming

Introduction to Programming Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines

More information

Variables. Data Types.

Variables. Data Types. Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab. University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Second week Variables Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable.

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

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

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

PROGRAMMING IN C++ COURSE CONTENT

PROGRAMMING IN C++ COURSE CONTENT PROGRAMMING IN C++ 1 COURSE CONTENT UNIT I PRINCIPLES OF OBJECT ORIENTED PROGRAMMING 2 1.1 Procedure oriented Programming 1.2 Object oriented programming paradigm 1.3 Basic concepts of Object Oriented

More information

Sahaj Computer Solutions OOPS WITH C++

Sahaj Computer Solutions OOPS WITH C++ Chapter 8 1 Contents Introduction Class Template Class Templates with Multiple Paramters Function Templates Function Template with Multiple Parameters Overloading of Template Function Member Function Templates

More information

IS 0020 Program Design and Software Tools

IS 0020 Program Design and Software Tools 1 IS 0020 Program Design and Software Tools Introduction to C++ Programming Spring 2005 Lecture 1 Jan 6, 2005 Course Information 2 Lecture: James B D Joshi Tuesdays/Thursdays: 1:00-2:15 PM Office Hours:

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

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

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++

CHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++ CHAPTER 9 C++ 1. WRITE ABOUT THE BINARY OPERATORS USED IN C++? ARITHMETIC OPERATORS: Arithmetic operators perform simple arithmetic operations like addition, subtraction, multiplication, division etc.,

More information

Basic Types, Variables, Literals, Constants

Basic Types, Variables, Literals, Constants Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic

More information

Programming with C++ Language

Programming with C++ Language Programming with C++ Language Fourth stage Prepared by: Eng. Samir Jasim Ahmed Email: engsamirjasim@yahoo.com Prepared By: Eng. Samir Jasim Page 1 Introduction: Programming languages: A programming language

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching

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

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

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words.

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words. , ean, arithmetic s s on acters Comp Sci 1570 Introduction to C++ Outline s s on acters 1 2 3 4 s s on acters Outline s s on acters 1 2 3 4 s s on acters ASCII s s on acters ASCII s s on acters Type: acter

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

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

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

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++

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

BITG 1233: Introduction to C++

BITG 1233: Introduction to C++ BITG 1233: Introduction to C++ 1 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

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

.Net Technologies. Components of.net Framework

.Net Technologies. Components of.net Framework .Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.

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

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

Input And Output of C++

Input And Output of C++ Input And Output of C++ Input And Output of C++ Seperating Lines of Output New lines in output Recall: "\n" "newline" A second method: object endl Examples: cout

More information

Chapter 2 - Control Structures

Chapter 2 - Control Structures Chapter 2 - Control Structures 1 Outline 2.1 Introduction 2.2 Algorithms 2.3 Pseudocode 2.4 Control Structures 2.5 if Selection Structure 2.6 if/else Selection Structure 2.7 while Repetition Structure

More information

Chapter 2 - Control Structures

Chapter 2 - Control Structures Chapter 2 - Control Structures 1 2.1 Introduction 2.2 Algorithms 2.3 Pseudocode 2.4 Control Structures 2.5 if Selection Structure 2.6 if/else Selection Structure 2.7 while Repetition Structure 2.8 Formulating

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

COMP322 - Introduction to C++ Lecture 02 - Basics of C++ COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.

More information

Sahaj Computer Solutions OOPS WITH C++

Sahaj Computer Solutions OOPS WITH C++ Chapter 6 1 Contents Introduction Types of Inheritances Defining the Derived Class Single Inheritance Making a private data inheritable Multilevel Inheritance Multiple Inheritance Ambiguity Resolution

More information

Programming Fundamentals. With C++ Variable Declaration, Evaluation and Assignment 1

Programming Fundamentals. With C++ Variable Declaration, Evaluation and Assignment 1 300580 Programming Fundamentals 3 With C++ Variable Declaration, Evaluation and Assignment 1 Today s Topics Variable declaration Assignment to variables Typecasting Counting Mathematical functions Keyboard

More information

Programming in C++ 4. The lexical basis of C++

Programming in C++ 4. The lexical basis of C++ Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

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

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

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

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

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

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING Unit I : OVERVIEW PART A (2 Marks) 1. Give some characteristics of procedure-oriented

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

AN OVERVIEW OF C++ 1

AN OVERVIEW OF C++ 1 AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function

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

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

Chapter 7. Additional Control Structures

Chapter 7. Additional Control Structures Chapter 7 Additional Control Structures 1 Chapter 7 Topics Switch Statement for Multi-Way Branching Do-While Statement for Looping For Statement for Looping Using break and continue Statements 2 Chapter

More information

CSCI 123 Introduction to Programming Concepts in C++

CSCI 123 Introduction to Programming Concepts in C++ CSCI 123 Introduction to Programming Concepts in C++ Brad Rippe C++ Basics C++ layout Include directive #include using namespace std; int main() { } statement1; statement; return 0; Every program

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

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

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are: LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words

More information

Operators in java Operator operands.

Operators in java Operator operands. Operators in java Operator in java is a symbol that is used to perform operations and the objects of operation are referred as operands. There are many types of operators in java such as unary operator,

More information

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions. Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 Certified CRISL rated 'A'

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

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

Assignment Operations

Assignment Operations ECE 114-4 Control Statements-2 Dr. Z. Aliyazicioglu Cal Poly Pomona Electrical & Computer Engineering Cal Poly Pomona Electrical & Computer Engineering 1 Assignment Operations C++ provides several assignment

More information

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 - Control Structures

Chapter 2 - Control Structures Chapter 2 - Control Structures 1 Outline 2.1 Introduction 2.2 Algorithms 2.3 Pseudocode 2.4 Control Structures 2.5 if Selection Structure 2.6 if/else Selection Structure 2.7 while Repetition Structure

More information

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PROGRAMMING Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PARADIGM Object 2 Object 1 Data Data Function Function Object 3 Data Function 2 WHAT IS A MODEL? A model is an abstraction

More information

A flow chart is a graphical or symbolic representation of a process.

A flow chart is a graphical or symbolic representation of a process. Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of

More information

BCA-105 C Language What is C? History of C

BCA-105 C Language What is C? History of C C Language What is C? C is a programming language developed at AT & T s Bell Laboratories of USA in 1972. It was designed and written by a man named Dennis Ritchie. C seems so popular is because it is

More information

C++ Quick Guide. Advertisements

C++ Quick Guide. Advertisements C++ Quick Guide Advertisements Previous Page Next Page C++ is a statically typed, compiled, general purpose, case sensitive, free form programming language that supports procedural, object oriented, and

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

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

CprE 288 Introduction to Embedded Systems Exam 1 Review.  1 CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements

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

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

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

cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... C++ vs Java identifiers.

cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... C++ vs Java identifiers. cs3157: c++ lecture #2 (mon-11-apr-2005) chronology of some programming languages... today: language basics: identifiers, data types, operators, type conversions, branching and looping, program structure

More information

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please

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

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

Unit-II Programming and Problem Solving (BE1/4 CSE-2)

Unit-II Programming and Problem Solving (BE1/4 CSE-2) Unit-II Programming and Problem Solving (BE1/4 CSE-2) Problem Solving: Algorithm: It is a part of the plan for the computer program. An algorithm is an effective procedure for solving a problem in a finite

More information

Programming, numerics and optimization

Programming, numerics and optimization Programming, numerics and optimization Lecture A-2: Programming basics II Łukasz Jankowski ljank@ippt.pan.pl Institute of Fundamental Technological Research Room 4.32, Phone +22.8261281 ext. 428 March

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 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

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

1

1 History of C++ & what is C++ During the 60s, while computers were still in an early stage of development, many new programming languages appeared. Among them, ALGOL 60, was developed as an alternative

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

CS201 Some Important Definitions

CS201 Some Important Definitions CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

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

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University) Estd: 1994 JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli - 621014 (An approved by AICTE and Affiliated to Anna University) ISO 9001:2000 Certified Subject Code & Name : CS 1202

More information

LEXICAL 2 CONVENTIONS

LEXICAL 2 CONVENTIONS LEXIAL 2 ONVENTIONS hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. ++ Programming Lexical onventions Objectives You will learn: Operators. Punctuators. omments. Identifiers. Literals. SYS-ED \OMPUTER EDUATION

More information

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires

More information

This tutorial adopts a simple and practical approach to describe the concepts of C++.

This tutorial adopts a simple and practical approach to describe the concepts of C++. About the Tutorial C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various

More information

EP241 Computer Programming

EP241 Computer Programming EP241 Computer Programming Topic 2 Dr. Ahmet BİNGÜL Department of Engineering Physics University of Gaziantep Modifications by Dr. Andrew BEDDALL Department of Electric and Electronics Engineering Sep

More information

Computers Programming Course 7. Iulian Năstac

Computers Programming Course 7. Iulian Năstac Computers Programming Course 7 Iulian Năstac Recap from previous course Operators in C Programming languages typically support a set of operators, which differ in the calling of syntax and/or the argument

More information

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT Two Mark Questions UNIT - I 1. DEFINE ENCAPSULATION. Encapsulation is the process of combining data and functions

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

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

More information

C++ INDEX. Introduction: Instructions for use. Basics of C++: Structure of a program Variables. Data Types. Constants Operators Basic Input/Output

C++ INDEX. Introduction: Instructions for use. Basics of C++: Structure of a program Variables. Data Types. Constants Operators Basic Input/Output INDEX Introduction: Instructions for use Basics of : Structure of a program Variables. Data Types. Constants Operators Basic Input/Output Control Structures: Control Structures Functions (I) Functions

More information

Chapter 1. Principles of Object Oriented Programming

Chapter 1. Principles of Object Oriented Programming Chapter 1. Principles of Object Oriented Programming Procedure Oriented Programming Vs Object Oriented Programming Procedure Oriented Programming Object Oriented Programming Divided Into In POP, program

More information

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and

The Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Op. Use Description + x + y adds x and y x y

More information