MAN4A OBJECT ORIENTED PROGRAMMING WITH C++ Unit I - V

Size: px
Start display at page:

Download "MAN4A OBJECT ORIENTED PROGRAMMING WITH C++ Unit I - V"

Transcription

1 MAN4A OBJECT ORIENTED PROGRAMMING WITH C++ Unit I - V MAN4B Object Oriented Programming with C++ 1

2 UNIT 1 Syllabus Principles of object oriented programming(oops), object-oriented paradigm. Advantages OOPs concepts OOPs Languages. Models:-Class Model-State Model and Interaction Model. MAN4B Object Oriented Programming with C++ 2

3 Procedural Languages vs. Object-Oriented Languages Procedural programming is code that is broken into procedures it s a different way of thinking about how code interacts with data that s more linear. Procedures are functional bits of code that interact with and change data. With OOP, however, data and functions (attributes and methods) are bundled together within the object. This prevents the need for any shared or global data with OOP, which is a core difference between the two approaches. Traditional procedural languages like C and Pascal require you to think in terms of the computer rather than thinking in terms of the problem you re trying to solve. When it comes to creating reusable components in software, OOP is the clear winner. Reusability leads to efficiency, simplifying programming and creating shortcuts to software design. MAN4B Object Oriented Programming with C++ 3

4 Principles of object oriented programming(oops MAN4B Object Oriented Programming with C++ 4

5 C++ Features Classes User-defined types Operator overloading Attach different meaning to expressions such as a + b References Pass-by-reference function arguments Virtual Functions Dispatched depending on type at run time Templates Macro-like polymorphism for containers (e.g., arrays) Exceptions MAN4B Object Oriented Programming with C++ 5

6 Object Model MAN4B Object Oriented Programming with C++ 6

7 Classes A class is a new way of creating and implementing a user defined data type. Classes provide a method for packing together data of different types. Objects are variables of the type class. Once a class has been defined, we can create any number of objects belonging to that class. Each object is associated with the data of type class with which they are created. Ex class student { char name[20]; int roll num, mark1,mark2,mark3,total; float avg;}; For more about class click Classes and Object MAN4B Object Oriented Programming with C++ 7

8 Introduction-Modeling Concepts, Object-Oriented Modeling and Design is a way of thinking about problems using models organized around real world concepts. The fundamental construct is the object, which combines both data and behavior. An object has: state - descriptive characteristics behaviors - what it can do (or what can be done to it) The state of a bank account includes its account number and its current balance The behaviors associated with a bank account include the ability to make deposits and withdrawals Note that the behavior of an object might change its state MAN4B Object Oriented Programming with C++ 8

9 Class Model MAN4B Object Oriented Programming with C++ 9

10 Class cont.. Specifying a class : A class specification has two parts : 1) Class declaration 2) Class Function Definitions MAN4B Object Oriented Programming with C++ 10

11 Class Declaration MAN4B Object Oriented Programming with C++ 11

12 Data Abstraction The binding of data and functions together into a single entity is referred to as encapsulation. The members and functions declared under private are not accessible by members outside the class, this is referred to as data hiding. Instruments allowing only selected access of components to objects and to members of other classes is called as Data Abstraction. Or rather Data abstraction is achieved through data hiding. Data hiding is the key feature of object oriented programming-oops MAN4B Object Oriented Programming with C++ 12

13 DATA ABSTRACTION MAN4B Object Oriented Programming with C++ 13

14 Popular Object-Oriented Languages Simula, the first object-oriented programming language. Java. Python. Ruby. C++ Smalltalk. Visual Basic.NET. Objective-C: OOP is a core tenet of ios mobile app programming, and Objective-C is essentially the C language with an objectoriented layer Curl Delphi Eiffel MAN4B Object Oriented Programming with C++ 14

15 Benefits of object-oriented technology Ease of software design Productivity Easy testing, debugging, and maintenance It s reusable More thorough data analysis, less development time, and more accurate coding, thanks to OOP s inheritance method Data is safe and secure, with less data corruption, thanks to hiding and abstraction It s sharable (classes are reusable and can be distributed to other networks) MAN4B Object Oriented Programming with C++ 15

16 UNIT 2 SYLLABUS Introduction to C++-Tokens, Keywords Identifiers Variables Operators Manipulators Expressions Control Structures. MAN4B Object Oriented Programming with C++ 16

17 Introduction to C++-Tokens A token is the smallest element of a C++ program that is meaningful to the compiler. MAN4B Object Oriented Programming with C++ 17

18 Keywords These are some reserved words in C++ which have predefined meaning to compiler called keywords. Some of the Keyword are given bellow MAN4B Object Oriented Programming with C++ 18

19 Identifiers Symbolic names can be used in C++ for various data items used by a programmer in his program. A symbolic name is generally known as an identifier. The identifier is a sequence of characters taken from C++ character set. Identifier refers to name given to entities such as variables, functions, structures etc They are created to give unique name to a entity to identify it during the execution of the program The rule for the formation of an identifier are: An identifier can consist of alphabets, digits and/or underscores. It must not start with a digit C++ is case sensitive that is upper case and lower case letters are considered different from each other. It should not be a reserved word. MAN4B Object Oriented Programming with C++ 19

20 Variables A variable is used for storing a value either a number or a character and a variable also vary its value means it may change his value Variables are used for given names to locations in the Memory of Computer where the different constants are stored. these locations contain Integer,Real or Character Constants. For Naming a Variable There are Some Specific Rules A Variable name is any Combination of 1 to 8 alphabets digits or underscore. The First Character in the Variable name must be an alphabet No Commas or blanks spaces are allowed in variable name No Special Symbols are used in the name of the Variable. MAN4B Object Oriented Programming with C++ 20

21 Data types MAN4B Object Oriented Programming with C++ 21

22 Operators MAN4B Object Oriented Programming with C++ 22

23 MAN4B Object Oriented Programming with C++ 23

24 Control Structures. MAN4B Object Oriented Programming with C++ 24

25 Branching / Decision Making statements MAN4B Object Oriented Programming with C++ 25

26 If..else syntax of the if statement if (condition) { statement(s); } From the flowchart it is clear that if the if condition is true, statement is executed; otherwise it is skipped. The statement may either be a single or compound statement. syntax of the if - else statement if (condition) statement1; else statement2; The given condition is evaluated first. If the condition is true, statement1 is executed. If the condition is false, statement2 is executed. It should be kept in mind that statement and statement2 can be single or compound statement. MAN4B Object Oriented Programming with C++ 26

27 Switch Statement The if and if-else statements permit two way branching whereas switch statement permits multiple branching. The syntax of switch statement is: switch (var / expression) { case constant1 : statement 1; break; case constant2 : statement2; break;.. default: statement3; break; } MAN4B Object Oriented Programming with C++ 27

28 Switch case statement Some important points about switch statement The expression of switch statement must be of type integer or character type. The default case need not to be used at last case. It can be placed at any place. The case values need not to be in specific order. The execution of switch statement begins with the evaluation of expression. If the value of expression matches with the constant then the statements following this statement execute sequentially till it executes break. The break statement transfers control to the end of the switch statement. If the value of expression does not match with any constant, the statement with default is executed. MAN4B Object Oriented Programming with C++ 28

29 Looping statement It is also called a Repetitive control structure. Sometimes we require a set of statements to be executed a number of times by changing the value of one or more variables each time to obtain a different result. This type of program execution is called looping. C++ provides the following construct Entry Check while loop for loop Exit Check do-while loop MAN4B Object Oriented Programming with C++ 29

30 Looping Flow chart MAN4B Object Oriented Programming with C++ 30

31 Loop statement In general, a looping process would work in the following manner : 1. Initializes the condition variable 2. Executes the segment of the body 3. Increments the value of the condition variable as required 4. Tests the condition variable in the form of a relational expression. Based on the value of the relational expression the control is either transferred to the beginning of the block, or it quits the loop. MAN4B Object Oriented Programming with C++ 31

32 While Loop while <(condition)>{ } loop : is called as the entry-check loop. The basic syntax is : While(condition) { Statement } The body of the while loop will be executed only if the test expression results true placed in the while statement. The control exits the loop once the test expression is evaluated to false. MAN4B Object Oriented Programming with C++ 32

33 For loop for (; ; ).. loop : is an entry controlled loop and is used when an action is to be repeated for a predetermined number of times. The syntax is for(intial value ; test-condition ; increment) { action block; } The general working of for(;;)loop is : 1. The control variable is initialized the first time when the control enters the loop for the first time 2. Test condition is evaluated. The body of the loop is executed only if the condition is TRUE. Hence for(;;) loop is called as entry controlled loop 3. On repetition of the loop, the control variable is incremented and the test condition will be evaluated before the body of the loop is executed. 4. The loop is terminated when the test condition evaluates to false. MAN4B Object Oriented Programming with C++ 33

34 Do..while loop do while <(condition)> is called as exit- check loop, as the condition(test expression) marks the last statement of the body of the loop do.. while Loop : The construct of a do.. while loop is : do { action block } while <(condition)> MAN4B Object Oriented Programming with C++ 34

35 Branching continue The continue statement forces the next iteration of the loop to take place, skipping any code following the continue statement in the loop body Break A loop s execution is terminated when the test condition evaluates to false. Under certain situations one desires to terminate the loop, irrespective of the test expression for(int x=0; x<9;x++) { if (a[x] == search_item) {cout << \nitem found at position.. << x; break;} The goto statement goto allows to make jump to another point in the program. goto pqr; MAN4B Object Oriented Programming with C++ 35

36 Manipulators Some of the more commonly used manipulators are given below: endl Manipulator endl is the line feed operator in C++. It acts as a stream manipulator whose purpose is to feed the whole line and then point the cursor to the beginning of the next line. We can use \n (\n is an escape sequence) instead of endl for the same purpose. setw Manipulator This manipulator sets the minimum field width on output. Syntax: setw(x) MAN4B Object Oriented Programming with C++ 36

37 UNIT 3 Functions Main Function Function Prototyping Inline Functions Friend and Virtual Functions Parameters Passing in Functions Values Return by Functions MAN4B Object Oriented Programming with C++ 37

38 FUNCTIONS Functions are the building blocks of C++ programs. Functions are also the executable segments in a program. The starting point for the execution of a program is main ( ). Functions are advantageous as they Reduce the size of the program Reusability of code (function fact is executed more than once) A function can be shared by other programs by compiling it separately and loading them together. Youtube link for user defined function click here: Functions MAN4B Object Oriented Programming with C++ 38

39 Library Functions Mathematical FunctionsSome of the important mathematical functions in header file <math.h> are Function Meaning sin(x) Sine of an angle x (measured in radians) cos(x) Cosine of an angle x (measured in radians) Character Functions All the character functions require <ctype.h> header file. The following table lists the function. Function Meaning isalpha(c) It returns True if C is an uppercase letter and False if c is lowercase. isdigit(c) It returns True if c is a digit (0 through 9) otherwise False. String functions strcpy(str1, str2): Copies string str2 into string str1. strcat(str1, str2): Concatenates string str2 onto the end of string str1. strlen(str1): Returns the length of string str1. strcmp(str1, str2): Returns 0 if str1 and str2 are the same; less than 0 if str1<str2; greater than 0 if str1>str2. MAN4B Object Oriented Programming with C++ 39

40 Function definition and prototype The function definition consists of the function header and its body. The header is EXACTLY like the function prototype, EXCEPT that it contains NO terminating semicolon. //Prototyping, defining and calling a function #include <iostream> void starline(); // prototype the function int main() { starline( ); // function call cout<< "\t\tbjarne Stroustrup\n"; starline( ); // function call return 0; } // function definition void starline() { int count; // declaring a LOCAL variable for(count = 1; count <=65; count++) cout<< "*"; cout<<endl; } MAN4B Object Oriented Programming with C++ 40

41 Inline Functions Inline functions looks like a normal function in the source file but inserts the function code directly in the calling program Inline functions execute faster but required more memory space Some important points to be noted Function is made inline by putting a word inline in the beginning. Inline function should be declared before main() function. It does not have function prototype. Only shorter code is used in inline function If longer code is made inline then compiler ignores the request and it will be executed as normal function. inline int cube(int r) { return r*r*r; } MAN4B Object Oriented Programming with C++ 41

42 Friend and Virtual Functions A friend function of a class is defined outside that class' scope but it has the right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friends are not member functions. friend void printwidth( Box box ); A virtual function is a member function that you expect to be redefined in derived classes. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class's version of the function. virtual double GetBalance() { return _balance; MAN4B Object Oriented Programming with C++ 42

43 Parameters Passing in Functions Sometimes the calling function supplies some values to the called function. These are known as parameters. The variables which supply the values to a calling function called actual parameters. The variable which receive the value from called statement are termed formal parameters. Consider the following example that evaluates the area of a circle. #include<iostream void area(float); int main() { float radius; cin>>radius; area(radius); return 0; } void area(float r) { cout << the area of the circle is << 3.14*r*r << \n ; } Here radius is called actual parameter and r is called formal parameter. MAN4B Object Oriented Programming with C++ 43

44 Values Return by Functions The functions that return no value is declared as void. The data type of a function is treated as int, if no data type is explicitly mentioned. For example, int add (int, int); add (int, int); In both prototypes, the return value is int, because by default the return value of a function in C++ is of type int. Look at the following examples: SNo Function Prototype Return type 1 float power (float, int) Float 2 char choice ( ) char 3 char * success ( ) pointer to character MAN4B Object Oriented Programming with C++ 44

45 Categories of Functions For better understanding of arguments and return in functions, userdefined functions can be categorised as: Function with no argument and no return value Function with no argument but return value Function with argument but no return value Function with argument and return value For more details click : MAN4B Object Oriented Programming with C++ 45

46 UNIT 4 SYLLABUS Classes and Objects; Constructors and Destructors; Operator Overloading and Type Conversions Type of Constructors Function overloading. MAN4B Object Oriented Programming with C++ 46

47 Classes and Objects; Class: The building block of C++ that leads to Object Oriented programming is a Class. It is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class. A class is like a blueprint for an object. A Class is a user defined data-type which have data members and member functions. Data members are the data variables and member functions are the functions used to manipulate these variables and together these data members and member functions defines the properties and behavior of the objects in a Class. In the example of class Car, the data member will be speed limit, mileage etc and member functions can be apply brakes, increase speed etc. MAN4B Object Oriented Programming with C++ 47

48 OBJECTS An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated. Defining Class and Declaring Objects A class is defined in C++ using keyword class followed by the name of class. The body of class is defined inside the curly brackets and terminated by a semicolon at the end. MAN4B Object Oriented Programming with C++ 48

49 Class declaration MAN4B Object Oriented Programming with C++ 49

50 Creating object to a class You can create objects of Test class as follows: class Test { private: int data1; float data2; public: void function1() { data1 = 2; } float function2() { data2 = 3.5; return data2; } }; int main() { Test o1, o2; } Here, two objects o1 and o2 of Test class are created. MAN4B Object Oriented Programming with C++ 50

51 Accessing Class Members The members of a class are accessed using the dot operator. Test class o1 object will access data1 as O1.data The public data members are also accessed in the same way given however the private data members are not allowed to be accessed directly by the object. Accessing a data member depends solely on the access control of that data member. This access control is given by Access modifiers in C++. There are three access modifiers : public, private and protected. MAN4B Object Oriented Programming with C++ 51

52 Access Modifier MAN4B Object Oriented Programming with C++ 52

53 Example An Source Code Example: class MyClass { public: int a; protected: int b; private: int c; }; int main() { MyClass obj; obj.a = 10; //Allowed obj.b = 20; //Not Allowed, gives compiler error obj.c = 30; //Not Allowed, gives compiler error } MAN4B Object Oriented Programming with C++ 53

54 Inheritance and Access Specifiers First and most important rule Private members of a class are never accessible from anywhere except the members of the same class. All Public members of the Base Class become Public Members of the derived class All Protected members of the Base Class become Protected Members of the Derived Class. Private Inheritance: All Public members of the Base Class become Private Members of the Derived class & All Protected members of the Base Class become Private Members of the Derived Class. MAN4B Object Oriented Programming with C++ 54

55 Constructor and Destructor When an instance of a class comes into scope, a special function called the constructor gets executed. The constructor function initializes the class object. When a class object goes out of scope, a special function called the destructor gets executed. The constructor function name and the destructor have the same name as the class tag. Both the functions return nothing. They are not associated with any data type. MAN4B Object Oriented Programming with C++ 55

56 Constructors A constructor is a special type of member function that initialises an object automatically when it is created. Compiler identifies a given member function is a constructor by its name and the return type. Constructor has the same name as that of the class and it does not have any return type. Also, the constructor is always public. Functions of constructor 1) The constructor function initializes the class object 2) The memory space is allocated to an object MAN4B Object Oriented Programming with C++ 56

57 C++ Constructors Rules for constructor definition and usage 1) The name of the constructor must be same as that of the class 2) A constructor can have parameter list 3) The constructor function can be overloaded 4) The compiler generates a constructor, in the absence of a user defined constructor 5) The constructor is executed automatically MAN4B Object Oriented Programming with C++ 57

58 Destructors A destructor is a function that removes the memory of an object which was allocated by the constructor at the time of creating a object. It carries the same name as the class tag, but with a tilde ( ~) as prefix. Example : class simple { public : ~simple() {... } } MAN4B Object Oriented Programming with C++ 58

59 Rules for destructor definition and usage 1) The destructor has the same name as that of the class prefixed by the tilde character ~. 2) The destructor cannot have arguments 3) It has no return type 4) Destructors cannot be overloaded i.e., there can be only one destructor in a class 5) In the absence of user defined destructor, it is generated by the compiler 6) The destructor is executed automatically when the control reaches the end of class scope MAN4B Object Oriented Programming with C++ 59

60 Operator Overloading The term operator overloading, refers to giving additional functionality to the normal C++ operators like +,++,-,,+=,-=,*.<,>. The statement sum = num1 + num2 would be interpreted as a statement meant to perform addition of numbers(integer/float/double) and store the result in the variable sum. Now look at the following statement: name = first_name + last_name; where the variables name, first_name and last_name are all character arrays. Can one achieve concatenation of character arrays using + operator in C++? The functionality of + operator can be extended to strings through operator overloading. MAN4B Object Oriented Programming with C++ 60

61 Operator overloading provides 1. New function definitions for basic C++ operators like +, *, -,++, - -, >, <, += and the like. 2. One cannot overload C++ specific operators like membership operator (.), scope resolution operator (::), sizeof operator and conditional operator. 3. The overloaded function definitions are permitted for user defined data type. 4. Operator functions must be either member functions or friend functions. 5. The new definition that is provided to an operator does not overrule the original definition of the operator. MAN4B Object Oriented Programming with C++ 61

62 The process of overloading involves 1. Create a class that defines the data type that is to be used in the overloading operations 2. Declare the operator function operator () in the public part of the class. 3. Define the operator function to implement the required operations. MAN4B Object Oriented Programming with C++ 62

63 Type Conversions Implicit Conversion Explicit Conversion More Details On: MAN4B Object Oriented Programming with C++ 63

64 Implicit Conversions Implicit conversions are automatically performed when a value is copied to a compatible type. For example short a=2000; int b; b=a; Here, the value of a is promoted from short to int without the need of any explicit operator. This is known as a standard conversion. Standard conversions affect fundamental data types, and allow the conversions between numerical types (short to int, int to float, double to int...), to or from bool, and some pointer conversions. Converting to int from some smaller integer type, or to double from float is known as promotion, and is guaranteed to produce the exact same value in the destination type. Other conversions between arithmetic types may not always be able to represent the same value exactly: MAN4B Object Oriented Programming with C++ 64

65 Rules for implicit conversion: Consider a term, having a pair of operands and an operator. The conversions takes place as follows : 1. If one operand is of type long double, then the other value is also converted to long double. 2. If one operand is of type double, then the other value is also converted to double. 3. If one of the operands is a float, the other is converted to a float. 4. If one of the operands is an unsigned long int, the other is converted to unsigned long int. 5. If one of the operands is a long int, then the other is converted to long int. 6. If one of the operands is an unsigned int, then the other is converted to an unsigned int. MAN4B Object Oriented Programming with C++ 65

66 Explicit type conversion Explicit type conversion is a type conversion which is explicitly defined within a program (instead of being done by a compiler for implicit type conversion). It is defined by the user in the program. double da = 3.3; double db = 3.3; double dc = 3.4; int result = (int)da + (int)db + (int)dc; //result == 9 There are several kinds of explicit conversion. Checked: Before the conversion is performed, a runtime check is done to see if the destination type can hold the source value. If not, an error condition is raised. Unchecked: No check is performed. If the destination type cannot hold the source value, the result is undefined. bit pattern: The raw bit representation of the source is copied verbatim, and it is re-interpreted according to the destination type.. MAN4B Object Oriented Programming with C++ 66

67 Type of Constructors Normally Constructors are following type: Default Constructor or Zero argument constructor Parameterized constructor Copy constructor Conversion constructor Explicit constructor MAN4B Object Oriented Programming with C++ 67

68 Default Constructor Class add{ public: add() }; The constructor add() is a constructor without parameters(non parameterized). It is called as default constructor. More traditionally default constructors are referred to compiler generated constructors i.e., constructors defined by the computers in the absence of user defined constructor. A non- parameterized constructor is executed when an object without parameters is declared. MAN4B Object Oriented Programming with C++ 68

69 Parameterized Constructor This is Another type Constructor which has some Arguments and same name as class name but it uses some Arguments So For this We have to create object of Class by passing some Arguments at the time of creating object with the name of class. When we pass some Arguments to the Constructor then this will automatically pass the Arguments to the Constructor and the values will retrieve by the Respective Data Members of the Class. The constructor add ( int s1, int s2) is called as parameterized constructor. To invoke this constructor, the object should be declared with two integer constants or variables. Ref: MAN4B Object Oriented Programming with C++ 69

70 Copy constructor The constructor add (add &a ) is called as copy constructor. A copy constructor is executed: 1) When an object is passed as a parameter to any of the member functions Example void add::putdata( add x); 2) When a member function returns an object For example, add getdata(); 3) When an object is passed by reference to constructor For example, add a; b(a); MAN4B Object Oriented Programming with C++ 70

71 Function overloading. The ability of the function to process the message or data in more than one form is called as function overloading. You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You cannot overload function declarations that differ only by return type. Ways to overload a function By changing number of Arguments. By having different types of argument. MAN4B Object Oriented Programming with C++ 71

72 UNIT 5 Single Inheritance Inheritance Multilevel Inheritance Multiple Inheritance Hierarchical Inheritance Hybrid Inheritance. Virtual Functions and Polymorphism; Managing Console I/O operations. MAN4B Object Oriented Programming with C++ 72

73 Inherit Definition Inherit Definition - Derive quality and characteristics from parents or ancestors. Like you inherit features of your parents. Inheritance is the most powerful feature of an object oriented programming language. It is a process of creating new classes called derived classes, from the existing or base classes. The derived class inherits all the properties of the base class. It is a power packed class, as it can add additional attributes and methods and thus enhance its functionality. We are familiar with the term inheritance in real life (children acquire the features of their parents in addition to their own unique features). Similarly a class inherits properties from its base class MAN4B Object Oriented Programming with C++ 73

74 Inheritance MAN4B Object Oriented Programming with C++ 74

75 Inheritance cont Single Inheritance When a derived class inherits only from one base class, it is known as single inheritance Multiple Inheritance When a derived class inherits from multiple base classes it is known as multiple inheritance Multilevel Inheritance The transitive nature of inheritance is reflected by this form of inheritance. When a class is derived from a class which is a derived class itself then this is referred to as multilevel inheritance. Hierarchical Inheritance When there is a need to create multiple Derived classes that inherit properties of the same Base class is known as Hierarchical inheritance MAN4B Object Oriented Programming with C++ 75

76 Advantages of inheritance 1.Reusability of code : Many applications are developed in an organization. Code developed for one application can be reused in another application if such functionality is required. This saves a lot of development time. 2) Code sharing : The methods of the base class can be shared by the derived class. 3) Consistency of interface: The inherited attributes and methods provide a similar interface to the calling methods. The attributes and methods of the class vehicle are common to the three derived classes Aeroplane, Car and Bicycle. These three derived classes are said to be having a consistence interface. MAN4B Object Oriented Programming with C++ 76

77 Polymorphism The ability of an object to respond differently to different messages is called as polymorphism. Draw( side) is defined to draw a square Draw (length, breadth) - is defined to draw a rectangle Draw(radius) - is defined to draw a circle Draw(radius,start_angle,end_angle) to draw an arc The function draw() accepts different inputs and performs different functions accordingly. As far as the user is concerned, he will use the function draw() to draw different objects with different inputs. This differential response of the function draw() based on different inputs is what is called as polymorphism. MAN4B Object Oriented Programming with C++ 77

78 Managing Console I/O operations To perform input and output, a C++ program: Construct a stream object. Connect (Associate) the stream object to an actual IO device (e.g., keyboard, console, file, network, another program). Perform input/output operations on the stream, via the functions defined in the stream's pubic interface in a device independent manner. Some functions convert the data between the external format and internal format (formatted IO); while other does not (unformatted or binary IO). Disconnect (Dissociate) the stream to the actual IO device (e.g., close the file). Free the stream object. MAN4B Object Oriented Programming with C++ 78

79 Managing Console I/O operations More about IO operations : MAN4B Object Oriented Programming with C++ 79

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

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

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name

More information

+2 Volume II OBJECT TECHNOLOGY OBJECTIVE QUESTIONS R.Sreenivasan SanThome HSS, Chennai-4. Chapter -1

+2 Volume II OBJECT TECHNOLOGY OBJECTIVE QUESTIONS R.Sreenivasan SanThome HSS, Chennai-4. Chapter -1 Chapter -1 1. Object Oriented programming is a way of problem solving by combining data and operation 2.The group of data and operation are termed as object. 3.An object is a group of related function

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

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

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING

Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++

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

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++ No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)

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

CHOICE BASED CREDIT SYSTEM (With effect from )

CHOICE BASED CREDIT SYSTEM (With effect from ) B.Sc. Computer Science Syllabus Under the CHOICE BASED CREDIT SYSTEM (With effect from 2017-18) DEPARTMENT OF COMPUTER SCIENCE University College,TU,Nizamabad-503322 Syllabus for Computer Science (With

More information

Object Oriented Pragramming (22316)

Object Oriented Pragramming (22316) Chapter 1 Principles of Object Oriented Programming (14 Marks) Q1. Give Characteristics of object oriented programming? Or Give features of object oriented programming? Ans: 1. Emphasis (focus) is on data

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

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

- HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM

- HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM www.padasalai.net - HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM 1 A 26 D 51 C 2 C 27 D 52 D 3 C 28 C 53 B 4 A 29 B 54 D 5 B 30 B 55 B 6 A 31 C 56 A 7 B 32 C 57 D 8 C 33 B 58 C

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

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

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

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Object-Oriented Programming (OOP) Fundamental Principles of OOP Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is

More information

Sri Vidya College of Engineering & Technology

Sri Vidya College of Engineering & Technology UNIT I INTRODUCTION TO OOP AND FUNDAMENTALS OF JAVA 1. Define OOP. Part A Object-Oriented Programming (OOP) is a methodology or paradigm to design a program using classes and objects. It simplifies the

More information

Data Structures using OOP C++ Lecture 3

Data Structures using OOP C++ Lecture 3 References: th 1. E Balagurusamy, Object Oriented Programming with C++, 4 edition, McGraw-Hill 2008. 2. Robert L. Kruse and Alexander J. Ryba, Data Structures and Program Design in C++, Prentice-Hall 2000.

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

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018) Lesson Plan Name of the Faculty Discipline Semester :Mrs. Reena Rani : Computer Engineering : IV Subject: OBJECT ORIENTED PROGRAMMING USING C++ Lesson Plan Duration :15 weeks (From January, 2018 to April,2018)

More information

Quiz Start Time: 09:34 PM Time Left 82 sec(s)

Quiz Start Time: 09:34 PM Time Left 82 sec(s) Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability

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

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

CS201 Latest Solved MCQs

CS201 Latest Solved MCQs Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability

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

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE? 1. Describe History of C++? The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. One of the languages Stroustrup had the opportunity

More information

COIMBATORE EDUCATIONAL DISTRICT

COIMBATORE EDUCATIONAL DISTRICT COIMBATORE EDUCATIONAL DISTRICT REVISION EXAMINATION JANUARY 2015 STD-12 COMPUTER SCIENCE ANSEWR KEY PART-I Choose the Correct Answer QNo Answer QNo Answer 1 B Absolute Cell Addressing 39 C Void 2 D

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED

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

END TERM EXAMINATION

END TERM EXAMINATION END TERM EXAMINATION THIRD SEMESTER [BCA] DECEMBER 2007 Paper Code: BCA 209 Subject: Object Oriented Programming Time: 3 hours Maximum Marks: 75 Note: Attempt all questions. Internal choice is indicated.

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

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

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

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

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

KLiC C++ Programming. (KLiC Certificate in C++ Programming)

KLiC C++ Programming. (KLiC Certificate in C++ Programming) KLiC C++ Programming (KLiC Certificate in C++ Programming) Turbo C Skills: Pre-requisite Knowledge and Skills, Inspire with C Programming, Checklist for Installation, The Programming Languages, The main

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

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

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

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Data type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples:

Data type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples: Unit IV Pointers and Polymorphism in C++ Concepts of Pointer: A pointer is a variable that holds a memory address of another variable where a value lives. A pointer is declared using the * operator before

More information

An Object Oriented Programming with C

An Object Oriented Programming with C An Object Oriented Programming with C By Tanmay Kasbe Dr. Ravi Singh Pippal IDEA PUBLISHING WWW.ideapublishing.in i Publishing-in-support-of, IDEA PUBLISHING Block- 9b, Transit Flats, Hudco Place Extension

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

Object Oriented Programming

Object Oriented Programming Object Oriented Programming Course Title: Object Oriented Programming Full Marks: 60 20 20 Course No: CSC161 Pass Marks: 24 8 8 Nature of Course: Theory Lab Credit Hrs: 3 Semester: II Course Description:

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

PROGRAMMING IN C AND C++:

PROGRAMMING IN C AND C++: PROGRAMMING IN C AND C++: Week 1 1. Introductions 2. Using Dos commands, make a directory: C:\users\YearOfJoining\Sectionx\USERNAME\CS101 3. Getting started with Visual C++. 4. Write a program to print

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

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

STRUCTURING OF PROGRAM

STRUCTURING OF PROGRAM Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

Data Structures (list, dictionary, tuples, sets, strings)

Data Structures (list, dictionary, tuples, sets, strings) Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access

More information

Instantiation of Template class

Instantiation of Template class Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double

More information

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING SUB CODE / SUBJECT: CS1203 / Object oriented programming YEAR / SEM: II / III QUESTION BANK UNIT I FUNDAMENTALS PART-A (2 MARKS) 1. What is Object Oriented

More information

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity. OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.

More information

Padasalai.Net s Model Question Paper

Padasalai.Net s Model Question Paper Padasalai.Net s Model Question Paper STD: XII VOLUME - 2 MARKS: 150 SUB: COMPUTER SCIENCE TIME: 3 HRS PART I Choose the correct answer: 75 X 1 = 75 1. Which of the following is an object oriented programming

More information

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017 Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable

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

Fast Introduction to Object Oriented Programming and C++

Fast Introduction to Object Oriented Programming and C++ Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming

More information

Get Unique study materials from

Get Unique study materials from Downloaded from www.rejinpaul.com VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : IV Section : EEE - 1 & 2 Subject Code

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and

More information

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE PART A UNIT I 1. Differentiate object oriented programming from procedure oriented programming. 2. Define abstraction and encapsulation. 3. Differentiate

More information

C++ & Object Oriented Programming Concepts The procedural programming is the standard approach used in many traditional computer languages such as BASIC, C, FORTRAN and PASCAL. The procedural programming

More information

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

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object

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

CERTIFICATE IN WEB PROGRAMMING

CERTIFICATE IN WEB PROGRAMMING COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING YEAR/SEM:II & III UNIT I 1) Give the evolution diagram of OOPS concept. 2) Give some

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

A SHORT COURSE ON C++

A SHORT COURSE ON C++ Introduction to A SHORT COURSE ON School of Mathematics Semester 1 2008 Introduction to OUTLINE 1 INTRODUCTION TO 2 FLOW CONTROL AND FUNCTIONS If Else Looping Functions Cmath Library Prototyping Introduction

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

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

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

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

Module Operator Overloading and Type Conversion. Table of Contents

Module Operator Overloading and Type Conversion. Table of Contents 1 Module - 33 Operator Overloading and Type Conversion Table of Contents 1. Introduction 2. Operator Overloading 3. this pointer 4. Overloading Unary Operators 5. Overloading Binary Operators 6. Overloading

More information

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

Cpt S 122 Data Structures. Course Review Midterm Exam # 2 Cpt S 122 Data Structures Course Review Midterm Exam # 2 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 2 When: Monday (11/05) 12:10 pm -1pm

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object

More information

WYSE Academic Challenge Computer Science Test (Regional) 2015 Solution Set

WYSE Academic Challenge Computer Science Test (Regional) 2015 Solution Set WYSE Academic Challenge Computer Science Test (Regional) 2015 Solution Set 1. Correct Answer: B Encapsulation refers to hiding the data behind get and set methods to insure that those using the class cannot

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

Cpt S 122 Data Structures. Introduction to C++ Part II

Cpt S 122 Data Structures. Introduction to C++ Part II Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function

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

Object-Oriented Design (OOD) and C++

Object-Oriented Design (OOD) and C++ Chapter 2 Object-Oriented Design (OOD) and C++ At a Glance Instructor s Manual Table of Contents Chapter Overview Chapter Objectives Instructor Notes Quick Quizzes Discussion Questions Projects to Assign

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,

More information

CHAPTER 4 FUNCTIONS. 4.1 Introduction

CHAPTER 4 FUNCTIONS. 4.1 Introduction CHAPTER 4 FUNCTIONS 4.1 Introduction Functions are the building blocks of C++ programs. Functions are also the executable segments in a program. The starting point for the execution of a program is main

More information

CS6301 PROGRAMMING AND DATA STRUCTURES II QUESTION BANK UNIT-I 2-marks ) Give some characteristics of procedure-oriented language. Emphasis is on doing things (algorithms). Larger programs are divided

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

Syllabus of C++ Software for Hands-on Learning: This course offers the following modules: Module 1: Getting Started with C++ Programming

Syllabus of C++ Software for Hands-on Learning: This course offers the following modules: Module 1: Getting Started with C++ Programming Syllabus of C++ Software for Hands-on Learning: Borland C++ 4.5 Turbo C ++ V 3.0 This course offers the following modules: Module 1: Getting Started with C++ Programming Audience for this Course Job Roles

More information

Module 10 Inheritance, Virtual Functions, and Polymorphism

Module 10 Inheritance, Virtual Functions, and Polymorphism Module 10 Inheritance, Virtual Functions, and Polymorphism Table of Contents CRITICAL SKILL 10.1: Inheritance Fundamentals... 2 CRITICAL SKILL 10.2: Base Class Access Control... 7 CRITICAL SKILL 10.3:

More information