QUESTIONS AND ANSWERS. 1) To access a global variable when there is a local variable with same name:
|
|
- Clara Cook
- 5 years ago
- Views:
Transcription
1 Q1. List the usage of :: operator in C++. [AYUSH BANIK ] QUESTIONS AND ANSWERS 1) To access a global variable when there is a local variable with same name: int x; // Global x int main() int x = 10; // Local x cout << "Value of global x is " << ::x; cout << "\nvalue of local x is " << x; return 0; 2) To define a function outside a class. class A public: // Only declaration void fun(); ; // Definition outside class using :: void A::fun() cout << "fun() called"; int main() A a; a.fun(); return 0;
2 Q2. Define message passing. [AYUSH BANIK ] Ans) Objects communicate with one another by sending and receiving information to each other. A message for an object is a request for execution of a procedure and therefore will invoke a function in the receiving object that generates the desired results. Message passing involves specifying the name of the object, the name of the function and the information to be sent. Following are the basic steps in message passing. Creating classes that define objects and its behaviour. Creating objects from class definitions Q3) List any two limitations of Object Oriented Programming. (AYUSH KUMAR KAYAL, ) Ans) Any two limitations of object oriented programming are: 1. Solving a problem using OOP approach consumes more time than the time taken by structured programming approach. 2. Not all programs can be modeled accurately by the objects model. If we just want to read in some data, do something simple to it and write it back out, we have no need to define classes and objects. However, in some OOP languages, we may have to perform this extra step. Q4) Explain Input, Output and Cascading of I/O operators with suitable examples. (AYUSH KUMAR KAYAL, ) Ans) INPUT: If the direction of flow of bytes is from device(for example: Keyboard) to the main memory then this process is called input. The standard input device is usually the keyboard. Handling the standard input in C++ is done by applying the overloaded operator of extraction(>>) on the cin stream. The operator must be followed by the variable that will store the data. The extraction operator extracts the data from the object cin which is entered using the keyboard. Example: #include<iostream> using namespace std;
3 int main() int age; cout << "Enter your age:"; cin >> age; cout << "\nyour age is: "<<age; // The input is taken here and stored. return 0; OUTPUT: If the direction of flow of bytes is opposite, i.e. from main memory to device( display screen ) then this process is called output. We know the standard output of a program is the screen, and the C++ stream object defined to access it is cout. cout is used in conjunction with the insertion operator, which is written as <<. #include <iostream> using namespace std; int main( ) int total =98; cout<< Total value: <<total<<endl; // cout is used to access the output return 0; Cascading of I/O operators: The cascading of the input and output operators refers to the consecutive occurrence of input or output operators in a single statement. A program with cascading of the input/output operator #include<iostream> using namespace std; int main () int a, b; cin>>a>>b; Cout<<"The value of a is : "<<a<<"and the value of b is : "<<b<<endl;
4 return 0; Here, the input is not taken separately for each variable w and similarly multiple output operators can be used in a single line which is known as cascading. It can be observed that cascading of the input/output operator improves the readability and reduces the size of the program. Q5. Define Data Abstraction? [ARPITHA TESS JOSEPH ] Ans) Abstraction is representing essential features without icluding background information or explanation.it abstacts information or attributes.it is done by using data members because they hold information. Q6. Explain the concept of data sharing in user defined member function in C++? [ARPITHA TESS JOSEPH ] Ans) Data sharing in user member function can be implemented by PASSING DATA FROM ONE FUNCTION TI ANOTHER. Exmple: Private: Void input() Int x; Cout<< enter number <<endl; Cin>>x; Fact(x); Void fact(int n) Int f=1,i; For(i=1;i<=n;i++)
5 F=f*I; Cout<< factorial= <<f; Q7. Develop a function using reference variables (& symbol) as arguments to swap a pair of integers in C++ [ANIKET PAUL ] Ans) void swap(int &a,int &b) int c; c=a; a=b; b=c; cout<<"\ninside function after swapping\nvalue of A is"<<a<<"\nvalue of B is"<<b; Q8. Develop a C++ program to demonstrate enumeration data types with suitable examples. [ANIKET PAUL Ans) #include <iostream> using namespace std; enum seasons spring = 34, summer = 4, autumn = 9, winter = 32; int main() seasons s; s = summer; cout << "Summer = " << s << endl; return 0; Output Summer = 4
6 Q9. List the benefits of object-oriented programming. [AMBER UJJUWAL LINDA ] Ans) ->Benefits of object-oriented programming are: - Objects created for Object Oriented Programs can easily be reused in other programs. Once an Object is created, knowledge of its implementation is not necessary for its use. In older programs, coders needed understand the details of a piece of code before using it. Objects have the ability to hide certain parts of themselves from programmers. This prevents programmers from tampering with values they shouldn't. The object controls how one interacts with the values, preventing other kinds of errors. For example, a programmer (or another program) cannot set the width of a window to It provides a clear modular structure for programs which makes it good for defining abstract datatypes in which implementation details are hidden. Objects can also be reused within and across applications. It makes software easier to maintain. Since the design is modular, part of the system can be updated. Reuse also enables faster development. Object-oriented programming languages come with rich libraries of objects, and code developed during projects is also reusable in future projects. It provides a good framework for code libraries where the supplied software components can be easily adapted and modified by the programmer. This is particularly useful for developing graphical user interfaces. Better Productivity as OOP techniques enforce rules on a programmer that, in the long run, help her get more work done; finished programs work better, have more features and are easier to read and maintain. Multiple instance of an object can co-exist Polymorphism: the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends on the data types used in the operation. Polymorphism is extensively used in implementing Inheritance. Q10. Explain the unique advantages of using an object-oriented programming principle for develop big projects. [AMBER UJJUWAL LINDA ] Ans) Advantages of using an object-oriented programming to develop big projects are: I. Design Benefits: Large programs are very difficult to write. Object Oriented Programs force designers to go through an extensive planning phase, which makes for better
7 designs with less flaws. In addition, once a program reaches a certain size, Object Oriented Programs are actually easier to program than non-object-oriented ones. II. III. IV. Software Maintenance: Programs are not disposable. Legacy code must be dealt with on a daily basis, either to be improved upon (for a new version of an exist piece of software) or made to work with newer computers and software. An Object-Oriented Program is much easier to modify and maintain than a non-object-oriented Program. So, although a lot of work is spent before the program is written, less work is needed to maintain it over time. Better Productivity as OOP techniques enforce rules on a programmer that, in the long run, help her get more work done; finished programs work better, have more features and are easier to read and maintain. OOP programmers take new and existing software objects and "stitch" them together to make new programs. Because object libraries contain many useful functions, software developers don't have to reinvent the wheel as often; more of their time goes into making the new program. That s the beauty of encapsulation. Objects are self-contained, and each bit of functionality does its own thing while leaving the other bits alone. Also, this modality allows an IT team to work on multiple objects simultaneously while minimizing the chance that one person might duplicate someone else s functionality. V. Object-oriented programming languages allows you to break down your software into bite-sized problems that you then can solve one object at a time. Q11. List two types of comments in C++? [ABHISHEK RATHI ] Ans)Comments are portions of the code ignored by the compiler which allow the user to make simple notes in the relevant areas of the source code. Comments come either in block form or as single lines. Single-line comments (informally, C++ style), start with // and continue until the end of the line. If the last character in a comment line is a \ the comment will continue in the next line. Multi-line comments (informally, C style), start with /* and end with */.
8 12) Explain any four differences between Procedure oriented programming and Object-Oriented Programming? [ABHISHEK RATHI ] Ans) BASIS Divided Into PROCEDURE ORIENTED PROGRAMMING In POP, program is divided into small parts called functions. Approach POP follows Top Down approach. Access POP does not have any access Specifiers specifier. OBJECT ORIENTED PROGRAMMING In OOP, program is divided into parts called objects. OOP follows Bottom Up approach. OOP has access specifiers named Public, Private, Protected, etc. Examples Example of POP are : C, VB, FORTRAN, Pascal. Example of OOP are : C++, JAVA, VB.NET, C#.NET. 13)Scope resolution operator (::) in C++ programming language is used to define a function outside a class or when we want to use a global variable but also has a local variable with the same name. [AASTHA SACHDEVA ] Ans) Example : #include <iostream> using namespace std; char c = 'a'; // global variable int main() char c = 'b'; //local variable cout << "Local variable: " << c << "\n"; cout << "Global variable: " << ::c << "\n"; //using scope resolution operator return 0;
9 OUTPUT: Local variable:b Global variable:a 2. Scope Resolution Operator in class #include <iostream> using namespace std; class programming public: void output(); //function declaration ; // function definition outside the class void programming::output() cout << "Function defined outside the class.\n"; int main() programming x; x.output(); return 0; OUTPUT: Function defined outside the class. 14)List any two Object oriented programming languages other than C++. [ABHISHEK TM ] Ans) The other object oriented programs are java and python. 15)What is a class? Write a program explaining the class declaration and definition. [ABHISHEK TM ] Ans) 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
10 functions, which can be accessed and used by creating an instance of that class. A class is like a blueprint for an object. using namespace std; class student public: string studentname; int id; void printname(); void printid() cout << "Geek id is: " << id; ; Void student::printname() cout << "studentname is: " << studentname; int main() student obj1; obj1.studentname = "xyz"; obj1.id=15; obj1.printname(); cout << endl; obj1.printid(); return 0;
11 Q16. Data Types in c++? [AASTHA SACHDEVA ] Ans) Data types in C++ is mainly divided into two types: 1. Primitive Data Types: These data types are built-in or predefined data types and can be used directly by the user to declare variables. example: int, char, float, bool etc. Primitive data types available in C++ are: o Integer o Character o Boolean o Floating Point o Double Floating Point o Valueless or Void o Wide Character 2. Abstract or user defined data type: These data types are defined by user itself. Like, defining a class in C++ or a structure. Integer: Keyword used for integer data types is int. Integers typically requires 4 bytes of memory space and ranges from to Character: Character data type is used for storing characters. Keyword used for character data type is char. Characters typically requires 1 byte of memory space and ranges from to 127 or 0 to 255. Boolean: Boolean data type is used for storing boolean or logical values. A boolean variable can store either true or false. Keyword used for boolean data type is bool. Floating Point: Floating Point data type is used for storing single precision floating point values or decimal values. Keyword used for floating point data type is float. Float variables typically requires 4 byte of memory space. Double Floating Point: Double Floating Point data type is used for storing double precision floating point values or decimal values. Keyword used for double floating point data type is double. Double variables typically requires 8 byte of memory space. void: Void means without any value. void datatype represents a valueless entity. Void data type is used for those function which does not returns a value. 3. Datatype Modifiers: As the name implies, datatype modifiers are used with the builtin data types to modify the length of data that a particular data type can hold. Data type modifiers available in C++ are:
12 Signed Unsigned Short Long Q17. Explain the usage of array of objects in a class with example. [ANIT VIJAY ] Ans) An object of class represents a single record in memory, if we want more than one record of class type, we have to create an array of class or object. As we know, an array is a collection of similar type, therefore an array can be a collection of class type. Class diagram class class-name datatype var1; datatype var2; datatype varn; ; method1(); method2(); methodn(); class-name obj[ size ]; PROGRAM: #include<iostream.h> #include<conio.h> class Employee int Id; char Name[25]; int Age; long Salary; public: void GetData() //Statement 1 : Defining GetData()
13 cout<<"\n\tenter Employee Id : "; cin>>id; cout<<"\n\tenter Employee Name : "; cin>>name; cout<<"\n\tenter Employee Age : "; cin>>age; cout<<"\n\tenter Employee Salary : "; cin>>salary; void PutData() //Statement 2 : Defining PutData() cout<<"\n"<<id<<"\t"<<name<<"\t"<<age<<"\t"<<salary; ; void main() int i; Employee E[3]; //Statement 3 : Creating Array of 3 Employees Output : for(i=0;i<3;i++) cout<<"\nenter details of "<<i+1<<" Employee"; E[i].GetData(); cout<<"\ndetails of Employees"; for(i=0;i<3;i++) E[i].PutData();
14 Enter details of 1 Employee Enter Employee Id : 101 Enter Employee Name : Suresh Enter Employee Age : 29 Enter Employee Salary : Enter details of 2 Employee Enter Employee Id : 102 Enter Employee Name : Mukesh Enter Employee Age : 31 Enter Employee Salary : Enter details of 3 Employee Enter Employee Id : 103 Enter Employee Name : Ramesh Enter Employee Age : 28 Enter Employee Salary : Details of Employees 101 Suresh Mukesh Ramesh Q18. Create a class to represent a vector (single dimensional array). Include member functions to perform the following tasks. A) to create the vector B) To modify the value of a given element C) To multiply a scalar value. [ANIT VIJAY ] Ans) #include <iostream.h> #include <conio.h> intconst size=50; class vector float d[size]; int s; public:
15 void create(void); void modify(void); void multiply(void); void display(void); ; void vector :: create(void) cout<<"\n\nenter of Array you want to create:-"; cin>>s; cout<<"enter "<<s<<" Real Numbers\n"; for(int i=0;i<s;i++) cin>>d[i]; void vector :: modify(void) int mfy_value; float with; cout<<"\nenter Location of array at which value is to be modified:-"; cin>>mfy_value; cout<<"enter Value with which you want to Replace:-"; cin>>with; d[mfy_value]=with; void vector :: multiply(void) int mul; cout<<"\nenter value with which you want to multiply:-"; cin>>mul; for(int i=0;i<s;i++) d[i]=d[i]*mul;
16 void vector :: display(void) cout<<"\n\ndisplay of Array\n"; cout<<"("; for(int i=0;i<s;i++) cout<<d[i]; if(i!=s-1) cout<<","; cout<<")"; void main() clrscr(); vector o1; int choice; do cout<<"\n\nchoice List\n"; cout<<"1) To Create Vector Array\n"; cout<<"2) To Modify Array\n"; cout<<"3) To Multiply with Scalar value\n"; cout<<"4) To Display\n"; cout<<"5) EXIT\n"; cout<<"enter your choice:-"; cin>>choice; switch(choice) case 1: o1.create(); break; case 2: o1.modify();
17 break; case 3: o1.multiply(); break; case 4: o1.display(); break; case 5:goto end; while(1); end: Q19. List any six special characteristics of constructors. [ARJUN JOSHUA ] Ans) They should be declared in the public section. They are invoked directly when an object is created. They don t have return type, not even void and hence can t return any values. Constructors can be inside the class definition or outside the class definition. They can t be inherited (although a derived class can call the base class constructor) Like other C++ functions, they can have default arguments. Q20. Explain dynamic initialization of objects using a class. [ARJUN JOSHUA ] Ans) Dynamic initialization of object refers to initializing the objects at run time i.e. the initial value of an object is to be provided during run time. Dynamic initialization can be achieved using constructors and passing parameters values to the constructors. This type of initialization is required to initialize the class variables during run time. #include <iostream> using namespace std; class simple_interest
18 float principle, time, rate,interest; public: simple_interest (float a, float b, float c) principle = a; time =b; rate = c; void display ( ) interest =(principle* rate* time)/100; cout<<"interest ="<<interest ; ; int main() float p,r,t; cout<<"principle amount, time and rate"<<endl; cout<<" "<<endl; simple_interest s1(2000,7.5,2);//dynamic initialization s1.display(); return 1;
19
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 informationObject-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 informationUnit 1 : Principles of object oriented programming
Unit 1 : Principles of object oriented programming Difference Between Procedure Oriented Programming (POP) & Object Oriented Programming (OOP) Divided Into Importance Procedure Oriented Programming In
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II Year / Semester: III / V Date: 08.7.17 Duration: 45 Mins
More informationSTUDY 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 informationDownloaded from
Unit I Chapter -1 PROGRAMMING IN C++ Review: C++ covered in C++ Q1. What are the limitations of Procedural Programming? Ans. Limitation of Procedural Programming Paradigm 1. Emphasis on algorithm rather
More informationGovernment 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 informationDarshan Institute of Engineering & Technology for Diploma Studies
1. Explain Call by Value vs. Call by Reference Or Write a program to interchange (swap) value of two variables. Call By Value In call by value pass value, when we call the function. And copy this value
More informationPROGRAMMING 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 informationChapter 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 informationA 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 informationOBJECT 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 informationObject Oriented Programming. C++ 6 th Sem, A Div Ms. Mouna M. Naravani
Object Oriented Programming C++ 6 th Sem, A Div 2018-19 Ms. Mouna M. Naravani Object Oriented Programming (OOP) removes some of the flaws encountered in POP. In OOPs, the primary focus is on data rather
More informationData 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 informationBasic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable
Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is
More informationData 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 informationGE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004
GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 Functions and Program Structure Today we will be learning about functions. You should already have an idea of their uses. Cout
More informationScientific Computing
Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course
More informationLab # 02. Basic Elements of C++ _ Part1
Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special
More informationShort 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 informationCS2141 Software Development using C/C++ C++ Basics
CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short
More informationCS201 - 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 informationYour first C++ program
Your first C++ program #include using namespace std; int main () cout
More informationIntroduction to Programming EC-105. Lecture 2
Introduction to Programming EC-105 Lecture 2 Input and Output A data stream is a sequence of data - Typically in the form of characters or numbers An input stream is data for the program to use - Typically
More informationInput 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 informationC++ 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 informationPage. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team
Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team Question No: 1 ( Marks: 2 ) Write a declaration statement for an array of 10
More informationIntroduction to C++ (Extensions to C)
Introduction to C++ (Extensions to C) C is purely procedural, with no objects, classes or inheritance. C++ is a hybrid of C with OOP! The most significant extensions to C are: much stronger type checking.
More informationIntroduction 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 informationDHANALAKSHMI 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 informationCHRIST 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 informationObject 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 informationOOP THROUGH C++(R16) int *x; float *f; char *c;
What is pointer and how to declare it? Write the features of pointers? A pointer is a memory variable that stores the address of another variable. Pointer can have any name that is legal for other variables,
More informationChapter-11 POINTERS. Important 3 Marks. Introduction: Memory Utilization of Pointer: Pointer:
Chapter-11 POINTERS Introduction: Pointers are a powerful concept in C++ and have the following advantages. i. It is possible to write efficient programs. ii. Memory is utilized properly. iii. Dynamically
More informationFundamentals of Programming CS-110. Lecture 2
Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout
More informationCAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE
CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE a) Mention any 4 characteristic of the object car. Ans name, colour, model number, engine state, power b) What
More information6.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 informationUNIT- 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 informationADARSH 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 informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
More informationCreating 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 information2. First Program Stuff
CSE 232 First Midterm, Overview: 1. Getting Started 1. we got started 2. First Program Stuff 1. Compiler vs. Intepreter a. do you know all the steps to create an executable? 2. Variables are declared a.
More informationUnit - IV CHAPTER - 13 INTRODUCTION TO OOP WITH C++ Part 1 Choose the best answer
Unit - IV CHAPTER - 13 INTRODUCTION TO OOP WITH C++ Part 1 Choose the best answer 1. The term is used to describe a programming approach based on classes and objects is (A) OOP (B) POP (C) ADT (D) SOP
More informationCE221 Programming in C++ Part 1 Introduction
CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab
More informationChapter 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 informationChapter 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 informationIntroduction to Programming using C++
Introduction to Programming using C++ Lecture One: Getting Started Carl Gwilliam gwilliam@hep.ph.liv.ac.uk http://hep.ph.liv.ac.uk/~gwilliam/cppcourse Course Prerequisites What you should already know
More informationComputer 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- 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 informationPaytm 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 informationChapter 1: Object-Oriented Programming Using C++
Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms
More informationWelcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 1/9/ Review. Here s a simple C++ program:
Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams
More informationLab Instructor : Jean Lai
Lab Instructor : Jean Lai Group related statements to perform a specific task. Structure the program (No duplicate codes!) Must be declared before used. Can be invoked (called) as any number of times.
More informationIntroduction 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 informationFast 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 informationC++ PROGRAMMING BASICS
C++ Notes 1 By V. D. Gokhale C++ PROGRAMMING BASICS Difference between C and C++ :- (1) When we invoke turbo C++ editor by c:\tc\tc [Enter]. The editor window shows the file name with.c extension. [noname00.c].
More informationCE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings
CE221 Programming in C++ Part 2 References and Pointers, Arrays and Strings 19/10/2017 CE221 Part 2 1 Variables and References 1 In Java a variable of primitive type is associated with a memory location
More informationFundamentals of Programming. Lecture 19 Hamed Rasifard
Fundamentals of Programming Lecture 19 Hamed Rasifard 1 Outline C++ Object-Oriented Programming Class 2 C++ C++ began as an expanded version of C. C++ improves on many of C s features and provides object-oriented-programming
More informationCS 251 Intermediate Programming Methods and More
CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationCS3157: 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 informationSRM 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 informationObject Oriented Programming
F.Y. B.Sc.(IT) : Sem. II Object Oriented Programming Time : 2½ Hrs.] Prelim Question Paper Solution [Marks : 75 Q.1 Attempt the following (any THREE) [15] Q.1(a) Explain encapsulation? [5] (A) The wrapping
More informationAN 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 informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Subject Name: Object Oriented Programming
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may
More information(5-1) Object-Oriented Programming (OOP) and C++ Instructor - Andrew S. O Fallon CptS 122 (February 4, 2019) Washington State University
(5-1) Object-Oriented Programming (OOP) and C++ Instructor - Andrew S. O Fallon CptS 122 (February 4, 2019) Washington State University Key Concepts 2 Object-Oriented Design Object-Oriented Programming
More informationDr. Md. Humayun Kabir CSE Department, BUET
C++ Dr. Md. Humayun Kabir CSE Department, BUET History of C++ Invented by Bjarne Stroustrup at Bell Lab in 1979 Initially known as C with Classes Classes and Basic Inheritance The name was changed to C++
More informationJAVA GUI PROGRAMMING REVISION TOUR III
1. In java, methods reside in. (a) Function (b) Library (c) Classes (d) Object JAVA GUI PROGRAMMING REVISION TOUR III 2. The number and type of arguments of a method are known as. (a) Parameter list (b)
More informationBangalore South Campus
INTERNAL ASSESSMENT TEST 1(Solutions) Date :01/03/2017 Max Marks: 40 Subject& Code: Object Oriented Concepts (15CS45) Sem:VII ISE Name of the faculty: Miss Pragyaa Time: 90 minutes Note: Answer to all
More informationWelcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program:
Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams
More informationChapter 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 informationLecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University
Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types
More informationUnit-V File operations
Unit-V File operations What is stream? C++ IO are based on streams, which are sequence of bytes flowing in and out of the programs. A C++ stream is a flow of data into or out of a program, such as the
More informationIntro to Programming & C Why Program? 1.2 Computer Systems: Hardware and Software. Why Learn to Program?
Intro to Programming & C++ Unit 1 Sections 1.1-4 and 2.1-10, 2.12-13, 2.15-17 CS 1428 Spring 2019 Jill Seaman 1.1 Why Program? Computer programmable machine designed to follow instructions Program a set
More informationCS242 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 informationDE122/DC106 Object Oriented Programming with C++ DEC 2014
Q.2 a. Distinguish between Procedure-oriented programming and Object- Oriented Programming. Procedure-oriented Programming basically consists of writing a list of instructions for the computer to follow
More informationData Structures (INE2011)
Data Structures (INE2011) Electronics and Communication Engineering Hanyang University Haewoon Nam ( hnam@hanyang.ac.kr ) Lecture 1 1 Data Structures Data? Songs in a smartphone Photos in a camera Files
More informationCSCE 110 PROGRAMMING FUNDAMENTALS
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 2. Overview of C++ Prof. Amr Goneid, AUC 1 Overview of C++ Prof. Amr Goneid, AUC 2 Overview of C++ Historical C++ Basics Some Library
More informationSri 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 information3. Functions. Modular programming is the dividing of the entire problem into small sub problems that can be solved by writing separate programs.
1 3. Functions 1. What are the merits and demerits of modular programming? Modular programming is the dividing of the entire problem into small sub problems that can be solved by writing separate programs.
More informationProgramming. 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 informationFunctions. Introduction :
Functions Introduction : To develop a large program effectively, it is divided into smaller pieces or modules called as functions. A function is defined by one or more statements to perform a task. In
More informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
More informationI 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 informationOOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.
OOPs Concepts 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8. Type Casting Let us discuss them in detail: 1. Data Hiding: Every
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of MCA
INTERNAL ASSESSMENT Scheme and Solution -T2 Date : 30/3/2015 Max Marks : 50 Subject & Code : Object Oriented Programming with C++(13MCA22 ) Name of faculty : R.Jayanthi Time : 11.30 am -1.00 Pm Answer
More informationCS 251 Intermediate Programming Methods and Classes
CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationProgramming Language. Functions. Eng. Anis Nazer First Semester
Programming Language Functions Eng. Anis Nazer First Semester 2016-2017 Definitions Function : a set of statements that are written once, and can be executed upon request Functions are separate entities
More informationThe 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 informationOBJECTS. An object is an entity around us, perceivable through our senses. Types of Object: Objects that operate independently.
OBJECTS An object is an entity around us, perceivable through our senses. Types of Object: Objects that operate independently. Objects that work in associations with each others. Objects that frequently
More informationEECS402 Lecture 02. Functions. Function Prototype
The University Of Michigan Lecture 02 Andrew M. Morgan Savitch Ch. 3-4 Functions Value and Reference Parameters Andrew M. Morgan 1 Functions Allows for modular programming Write the function once, call
More informationChapter 1 INTRODUCTION
Chapter 1 INTRODUCTION A digital computer system consists of hardware and software: The hardware consists of the physical components of the system. The software is the collection of programs that a computer
More informationTEMPLATE IN C++ Function Templates
TEMPLATE IN C++ Templates are powerful features of C++ which allows you to write generic programs. In simple terms, you can create a single function or a class to work with different data types using templates.
More informationModule 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 informationBy 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 information2. Functions I: Passing by Value
Computer Science I CS 135 2. Functions I: Passing by Value René Doursat Department of Computer Science & Engineering University of Nevada, Reno Spring 2006 Computer Science I CS 135 0. Course Presentation
More information3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.
Chapter 2: Problem Solving Using C++ TRUE/FALSE 1. Modular programs are easier to develop, correct, and modify than programs constructed in some other manner. ANS: T PTS: 1 REF: 45 2. One important requirement
More informationMAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-I PART-A 1. What is
More informationC++ & 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 informationINTRODUCTION TO PROGRAMMING
FIRST SEMESTER INTRODUCTION TO PROGRAMMING COMPUTER SIMULATION LAB DEPARTMENT OF ELECTRICAL ENGINEERING Prepared By: Checked By: Approved By Engr. Najeeb Saif Engr. M.Nasim Kha Dr.Noman Jafri Lecturer
More informationOverview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program
Overview - General Data Types - Categories of Words - The Three S s - Define Before Use - End of Statement - My First Program a description of data, defining a set of valid values and operations List of
More information