chapter-1-object oriented programming

26
Prof.Manoj.Kavedia (9860174297) ([email protected]) Chapter-1 Q1. Write short note on software evolution Ans.C++ is an object-oriented programming language. It was developed by Bjarne Stroustrup at AT&T Bell Laboratories in Murray Hill, New Jersey, USA, in the early 1980’s. Stroustrup, an admirer of Simula67 and a strong supporter of C, wanted to combine the best of both the language and create a more powerful language that could support object-oriented programming features and still retain the power and elegance of C. The result was C++. Therefore, C++ is an extension of C with a major addition of the class construct feature of simula67. Since the class was a major addition to the original C language, Stroustrup initially called the new language ‘C with classes’. However, later in 1983, the name was changed to C++. The idea of C++ comes from the C increment operator ++, thereby suggesting that C++ is an augmented (incremented) version of C. During the early 1990’s the language underwent a number of improvements and changes. In November 1997, the ANSI/ISO standards committee standardized these changes and added several new features to the language specifications. C++ is a superset of C. Most of what we already know about C applies to C++ also. Therefore, most all C programs are also C++ programs. However, there are a few minor differences that will prevent a C program to run under compiler. The most important facilities that C++ adds on to C are classes, inheritance, function overloading, and operator overloading. These features enable creating of abstract data types, inherit properties from existing data types and support polymorphism, thereby making C++ a truly object-oriented language. The object-oriented features in C++ allow programmers to build large programs with clarity, extensibility and ease of maintenance, incorporating the spirit and efficiency of C. The addition of new features has transformed C from a language that currently facilitates top-down, structured design, to one that provides bottom-up, object-oriented design. Q2.Define OOP(object oriented programming) Ans. : Object Oriented programming is an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand. Thus an object is 1 1 Concept of Object Oriented Programming History & features: It’s need & requirement, procedure oriented programming versus object oriented programming, basic concepts object oriented programming, object oriented languages. Beginning with C++: Concepts & structure of C++ programming, concepts of structure. 1

Upload: jaikumarguwalani

Post on 03-Oct-2015

225 views

Category:

Documents


2 download

DESCRIPTION

Concept of object oriented programming

TRANSCRIPT

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    Chapter-1

    Q1. Write short note on software evolutionAns.C++ is an object-oriented programming language. It was developed by Bjarne Stroustrup at AT&T Bell Laboratories in Murray Hill, New Jersey, USA, in the early 1980s. Stroustrup, an admirer of Simula67 and a strong supporter of C, wanted to combine the best of both the language and create a more powerful language that could support object-oriented programming features and still retain the power and elegance of C. The result was C++.

    Therefore, C++ is an extension of C with a major addition of the class construct feature of simula67. Since the class was a major addition to the original C language, Stroustrup initially called the new language C with classes. However, later in 1983, the name was changed to C++.

    The idea of C++ comes from the C increment operator ++, thereby suggesting that C++ is an augmented (incremented) version of C.

    During the early 1990s the language underwent a number of improvements and changes. In November 1997, the ANSI/ISO standards committee standardized these changes and added several new features to the language specifications.

    C++ is a superset of C. Most of what we already know about C applies to C++ also. Therefore, most all C programs are also C++ programs. However, there are a few minor differences that will prevent a C program to run under compiler.

    The most important facilities that C++ adds on to C are classes, inheritance, function overloading, and operator overloading. These features enable creating of abstract data types, inherit properties from existing data types and support polymorphism, thereby making C++ a truly object-oriented language.

    The object-oriented features in C++ allow programmers to build large programs with clarity, extensibility and ease of maintenance, incorporating the spirit and efficiency of C. The addition of new features has transformed C from a language that currently facilitates top-down, structured design, to one that provides bottom-up, object-oriented design.

    Q2.Define OOP(object oriented programming)Ans. :Object Oriented programming is an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand. Thus an object is

    11Concept of Object

    Oriented ProgrammingHistory & features: Its need & requirement, procedure oriented programming versus object oriented programming, basic concepts object oriented programming, object oriented languages.Beginning with C++: Concepts & structure of C++ programming, concepts of structure.

    1

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    considered to be a partitioned area of computer memory that stores data and set of operations that can access that data.

    2

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    Q3.Explain what is the meaning of OOP and POPAns. Its approach is viewed as sequence of things to be done like reading, calculating and printing. Number of functions is written to accomplish these tasks. The primary focus is on function procedure of structured oriented programming is as shown.

    While we concentrate on development of function, very little attention is given to the data that are being used by various functions. Data is after all the reason for program existence. For e.g. the important part of the program is not the function that displays the data, or a function that checks the correct input. But yet the data is given secondary status in procedure oriented.

    Characteristics of POP (Procedure Oriented Programming)1. Emphasis is on doing things such as reading, calculating and printing.2. Large programs are divided into smaller one called as functions.3. Most of the functions share the global data.4. Data moves openly around the system.5. Implies top-down approach.6. New data type cant be handled easily as built in data types.

    Example : If we want to work with complex number which are user define data type they cant behave similar to built in data type. That is one complex number cant be added to another using + operator

    Object Oriented ProgrammingThe major motivation factor in the invention of OOPS is to solve the pitfalls

    encountered in POP. The organization of data and function in OOPS is shown below.

    Object1Data

    Function( )Object 2

    DataFunction ( )

    Object 3

    main()main()

    Function3Function3

    Function2Function2 Function1Function1

    3

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    DataFunction ( )

    The fundamental idea behind oops is to combine into single unit both data & functions such unit is called as object.The object members are referred as member functions in C++. Example. Think of the object as department in an organization such as sales, finance & personal. These departments provide an approach to cooperate the organization.

    Features of OOPS1. Emphasis is on data rather than procedures.2. Programs are divided into objects.3. Functions that operate on data of objects are tied together in data structure.4. Data is hidden and cannot be accessed by the external functions.5. Objects may communicate through functions.6. New data functions can be easily added.7. It is a bottom- up approach.

    Q4.List the drawbacks of Procedure oriented LanguagesAns.Disadvantages of Procedure oriented Language are

    1. No security for data. If we declare a variable before main function then it can be accessed freely from any function present in the program.

    2. No better memory management. 3. Difficult to implement today's client requirements. 4. No structure or code reusability. Hence time of development, testing and length

    of program increases. 5. As length of application increases it causes slow performance. 6. Code maintenance and enhancements are difficult. 7. No proper way method for Exception handling.

    Q5.What are the characteristics of Procedure oriented languagesAns.Characteristics of POP (Procedure Oriented Programming) are

    1. Emphasis is on doing things such as reading, calculating and printing.2. Large programs are divided into smaller one called as functions.3. Most of the functions share the global data.4. Data moves openly around the system.5. Implies top-down approach.6. New data type cant be handled easily as built in data types.

    Example. If we want to work with complex number which are user define data type they cant behave similar to built in data type. That is one complex number cant be added to another using + operator

    Q5.With the help of neat sketch show the relation of data and function in POP languagesAns. Procedure-oriented programming basically consists of writing a list of instructions (or actions) for the computer to follow and organizing these instructions into groups known as functions. We normally use a flowchart to organize these actions and represent

    4

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    the flow of control from one action to another. While we concentrate on the development of functions, very little attention is given to the data that are being used by various functions. What happens to the data? How are they affected by the functions that work on them?When there are more then one program, many important data items are placed as global so that they may be accessed by all the functions. Each function may have its own local data. Figure shows the relationship of data and functions in a procedure-oriented program.

    Global data are more vulnerable(Weak) to an inadvertent change by a function. In a large program it is very difficult to identify what data is used by which function. In case we need to revise an external data structure, we also need to revise all functions that access the data. This provides an opportunity for bugs to creep in. Another serious drawback with the procedural approach is that it does not mode real world problems very well. This is because functions are action-oriented and do not really correspond to the elements of the problem.

    Q7.What are the features of object oriented languageAns. Features of OOPS are

    1. Emphasis is on data rather than procedures.2. Programs are divided into objects.3. Functions that operate on data of objects are tied together in data structure.4. Data is hidden and cannot be accessed by the external functions.5. Objects may communicate through functions.6. New data functions can be easily added.7. It is a bottom- up approach.

    Q8. List and Describe basic concepts of OOPAns. Basic Concepts of OOPS are as follows :

    1. Objects2. Classes3. Data abstractions4. Data Encapsulation5. Inheritance

    5

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    6. Polymorphism7. Dynamic binding8. Message passing

    ObjectsObjects are basic run time entitles in an object oriented system. They may

    represent a person, a place, a bank account that a program must handle. They may also be a user defined functions such As vectors, date and time. Program object should be chosen such that they match closely the real World object. Example. Elements of computer user environment are windows, menus and graphics, objects.The physical objects are automobile in graphics stimulation, electronic component in circuit designing. The match between programming objects and a real world objects is a good resulting Objects offering the revolution in programming.For example: students objects includes the data members and functions as given:

    ClassesIn OOPS, The entire set of data & codes of an object can be made a user define

    data types. With the help of classes. A class is collection of objects of similar type. The objects are the members of classes almost all computer languages have built in data types like integer, float etc. In similar way you can define many objects of same class and the entire code of an object can be made a user define data type with the help of a class. A class is thus a collection of objects of similar type. For e.g staff and students are the members of the college.

    Data Abstraction and EncapsulationThe wrapping up of data and function into a single unit is called as

    Encapsulation. The data is not accessible to the outside world and only those functions, which are members of class, can access the data. These functions provide interface between objects and programs. This insulation of data from direct access by program is called as data hiding. Abstraction refers to the representation of essential features without including background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, cost, etc. Functions to operate on these attributes.

    Inheritance

    Data :NameData of BirthMarks

    Object : Student

    FunctionsTotalAverageDisplay

    Student

    Total

    Average

    Display

    6

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    It is a process by which the object of one class acquires the properties of objects of another class. It supports the concept of hierarchical classification. For e.g. sparrow is a part of class flying birds, which again is a part of class bird as, shown in fig. The principle behind this is that each derived class shares the common characteristics with the class from which it is derived.

    In OOPS, the concept of inheritance provides the idea of reusability if we can add additional features of an existing class without modifying it. This is possible by deriving a new class from existing one. The new class will have the combined features of both the classes.

    PolymorphismPolymorphism means the ability to take more than one form. For e.g. an operation

    may exhibit different behavior in different instants. The behavior depends upon the types of data used in the operation.For e.g. consider operation addition for two numbers, the operation will generate sum. If operands are strings the operation would perform a third string by concatenation. To handle function overloading, a single function name can be used to handle different numbers and different types of arguments. This is something similar to particular word having several different meanings depending upon the context as shown in the fig.

    Dynamic bindingBinding refers to a linking procedure call to the code, which is to be executed in

    response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of call at the run time.

    Consider a procedure draw shown in a fig by inheritance every object will have this procedure. This draw procedure will be redefined in each class that defines the object. At the run time, the code matching the object under current reference will be called.

    BIRDBIRD

    FLYING BIRDFLYING BIRD NON-FLYING BIRDNON-FLYING BIRD

    SPARROWSPARROW

    SHAPESHAPE

    CIRCLEDRAW( )

    CIRCLEDRAW( ) RECTANGLEDRAW( )

    RECTANGLEDRAW( )

    POLYGONDRAW( )

    POLYGONDRAW( )

    7

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    Message communicationAn object-oriented program consists of set of objects that communicate with each

    other. The process of programming in an object oriented language involves following basic steps: -

    1. Creating classes that define object and their behavior.2. Creating object from class definition.3. Establishing communication among object.Objects may communicate with one another by sending and receiving information

    through functions. A message for an object is a request for execution of a procedure. Therefore it evolves a function in receiving object that generates desired results.For example

    Employee.salary(name);Employee objectSalarymessageInformation information

    Q9.List the benefits of OOPSAns. OOP offers several benefits to both the program designer and the user. Object-orientation contributes to the solution of many problems associated with the development and quality of software products. The new technology promises greater programmer productivity, better quality of software and lesser maintenance cost. The principal advantages are:

    1. Through inheritance, we can eliminate redundant code and extend the use of existing classes.

    2. We can build programs from the standard working modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity.

    3. The principle of data hiding helps the programmer to build secure programs that cannot be invaded by code in other parts of the program.

    4. It is possible to have multiple instances of an object to co-exist without any interference.

    5. It is possible to map objects in the problem domain to those in the program.6. It is easy to partition the work in a project based on objects.7. The data-centered design approach Enables us to capture more details of a model

    in implement able form8. Object-oriented systems can be easily upgraded from small to large systems.9. Message passing techniques for communication between objects makes the

    interface descriptions with external systems much simpler.10. Software complexity can be easily managed.

    Q10.State the difference between OOP and POP languagesAns.

    POP (Procedure Oriented Language) OOP (Object Oriented Language)1.Data can be accessed by external functions.

    Data cant be accessed by external functions.

    2.It employees Top-Down Approach. It employees Bottom-Up approach.

    8

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    3.Programs are divided into functions. Programs are divided into objects.4.New data types can be easily handled.

    New data types can be easily handled.

    5.Most of the function share global data.

    Data structures are designed such that they characterize the object.

    Q11.Which Language are called as Object Based Programming LanguagesAns. Object Based Programming is the style of programming that support encapsulation & object identity. Major features of it are

    i. Data encapsulationii. Data hidingiii. Automatic installation iv. Operator overloading

    They dont support inheritance & dynamic binding. The example for object-based language is the language name is ADA.

    Q12.Which languages area called as Object oriented LanguagesAns. In corporate all object base programming features along with two additional features that is inheritance & dynamic binding. So Object oriented= Object based+ inheritance + Dynamic binding.The language that supports these features is C++, Small talk, Object Pascal & java. Usually the java is purely object-oriented language.

    Object Oriented LanguageLike the structure programming we can implement the concept of oops using the

    language such as C & PASCAL. But that becomes the confusion where the program grows larger. Hence a language that is specially designed to support OOPS languageThe language should support many concept of OOPS to claim that they are OOPS depending on the feature they support. They are classified in following two categories.

    1) Object Based Programming Language2) Object Oriented Programming Language

    1) Object Based Programming is the style of programming that support encapsulation & object identity. Major features of it are

    1. Data encapsulation2. Data hiding3. Automatic installation 4. Operator overloading

    They dont support inheritance & dynamic binding. The example for object-based language is the language name is ADA.

    2)Object Oriented Programming Language corporate all object base programming features along with two additional features that is inheritance & dynamic binding. So

    Object oriented= Object based+ inheritance + Dynamic binding.

    9

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    The language that supports these features is C++, Small talk, Object Pascal & java. Usually the java is purely object-oriented language.

    Q13.List characteristics of some OOP languagesAns.

    Q14. List some Object Oriented Language and Object based Programming LanguagesAns. Object oriented Languages

    C++ Small talk Object Pascal Java

    Object Based Programming languages ADA Visual BasicCardelli 85Modula-3

    10

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    Q15.State application of object oriented languagesAns.Applications of OOPS

    The concepts of OOPS are gaining importance in many areas. The most popular application has being in the area of

    1. Real-time systems2. Simulation and modeling3. Object-oriented databases4. Hypertext, hypermedia and expertext5. AI and expert systems6. Neural networks and parallel programming7. Decision support and office automation systems8. CIM/CAM/CAD systems

    Q16.Describe how data and Functions are organized in OOPAns. The major motivating factor in the invention of object-oriented approach is to remove some of the flaws encountered in the procedural approach. OOP treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the functions that operate on it, and protects it from accidental modification from outside functions.

    OOP allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects. The organization of data and functions in object-oriented programs is shown in Fig. The data and object can be accessed only by the functions associated with that object. However, functions of one object can access the functions of other objects.

    Q17.Why to use C++ as object oriented languageAns.

    1. Implementation details not related to the problem are isolated in the low-level parts of the other pieces of the program, e.g..., If we try to write a C program to read in two strings, concatenate them, and print the result, we are immediately

    11

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    distracted form our goal by the details of string processing. How long the string be? check to see if the allocation function failed, and remember to free the storage when no longer need it.

    2. If we build large programs with only procedural abstractions, we may have difficulty organizing and remembering all procedures

    3. Since each data abstraction can contain many procedures, data abstraction provides a way to group our procedures into large units. The most significant advantage of OOP is the way theprogrammer thinks about the program:

    4. A programmer working on operating system might think in terms of processes, device, and users

    5. A programmer working on windows system might think of things that can be displayed on the windows ( graphical images, text, etc..)

    6. OOP allows the programmer to create abstractions in the program that match these concepts C++ supplies all the language features of C, and adds features to support OOP. Language feature that support OOP includes:

    7. Support for data abstraction for user-defined types8. Features to let users work with user-defined types in the same ways they work

    with built-in types.9. Inheritance, a mechanism for grouping common features of several data

    abstractions10. Dynamic Binding 11. C programs can be re-coded in C++ with little or no loss of efficiency12. C++ like C, allows the programmer to bend the rule of data encapsulation

    Q18.Describe the structure of C++ programAns. It is a common practice to organize a program into three separate files. The class declarations are placed in a header file and the definitions of member functions go into

    another file This approach enables the programmer to separate the abstract specification of the interface (class definition) from the implementation details (member functions definition).

    Finally, the main program that uses the class is placed in a third file which includes the previous two files as well as any other files required.

    This approach is based on the concept of client-server model as shown in Fig. The class definition including the member functions constitute the server that provides services to the main program known as client.

    The client uses the server through the public interface of the class.

    Q19.State application of C++?Ans. C++ is a versatile language for handling very large programs. It is suitable for virtually any programming task including development of editors, compilers, databases, communication systems and any complex real-life application systems.

    12

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    Since C++ allows us to create hierarchy-related objects, we can build special object- oriented libraries which can be used later by many programmers.

    While C++ is able to map the real-world problem properly, the C part of C++ gives the language the ability to get close to the machine-level details.

    C++ programs are easily maintainable and expandable. When a new feature needs to be implemented, it is very easy to add to the existing structure of an object.

    It is expected that C++ will replace C as a general-purpose language in the near future.

    Q20.Describe some programming features of C++ programming language.Ans. Some Programming Features of C++Like C, the C++ program is a collection of functions. The program contains only one function main (). As usual, execution begins at main(). Every C++ program must have a main (). C++ is a free-form language. With a few exceptions, the compiler ignores carriage returns and white spaces. Like C, the C++ statements terminate with semicolons.

    Comment C++ introduces a new comment symbol (double slash). Comments start with a double slash symbol and terminate at the end of the line. A comment may start anywhere in the line, and whatever follows till the end of the line is ignored. Note that there is no closing symbol.

    // This is Example of C++We can use either or both styles in our programs.

    /* This is also example of oops using c++*/

    Output Operatorcout

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    This directive causes the preprocessor to add the contents of the iostream file to the program. It contains declarations for the identifier cout and the operator number1;is an input statement and causes the program to wait for the user to type in a number. The number keyed in is placed in the variable number1. The identifier cin (pronounced C in) is a predefined object in C++ that corresponds to the standard input stream. Here, this stream represents the keyboard.The operator >> is known as extraction or get from operator. It extracts (or takes) the value from the keyboard and assigns it to the variable on its right . This corresponds to the familiar scanf() operation. Like > can also be overloaded.

    Cascading the OperatorWe have used the insertion operator

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    int a;

    public: // public member function int f()

    { return a = 5;

    };};

    struct Y {

    // public by default int f()

    { return a = 5;

    };private: // private data member int a;

    };

    Q22.Compare Structure and ClassAns. In C++, a structure is a class defined with the struct keyword. Its members and base classes are public by default. A class defined with the class keyword has private members and base classes by default. This is the only difference between structs and classes in C++.Basically in C++ structure and class are same but with some minor differences listed below

    1. In classes all the members by default are private but in structure members are public by default.

    2. There is no term like constructor and destructor for structs, but for class compiler creates default if you don't provide.

    3. Sizeof empty structure is 0 Bytes were as Sizeof empty class is 1 Byte4. Inheritance between classes is also private by default, and inheritance between

    structs is public by default.5. Structures didnot support data hiding, but classes can.6. Private functions totally hidden in classes.7. classes support polymorphism, whereas structures donot

    Q.23.Compare C and C++ StructureAns.

    The definition of the structure in C is limited to within the module and cannot be initialized outside its scope. Where as in C++ you can initialize the objects anywhere within the boundaries of the project.

    The one more difference is in C++ structure we can have methods(procedures) but C can note have methods in structure

    15

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    By default C structure are Public while C++ structure are private. In C you can declare structure as struct A a; But not A a(which is possible in C++);

    Q.Compare POP and OOPAns.

    The object oriented program deals with objects created on the basis of classes example: java c++, but procedure oriented program deals with functions example:c , pascal

    In Procedural programming Programmer combines related sequences of statements into one single place called procedure. A procedure call is used to invoke the procedure. After the sequence is processed flow of control proceeds right after the position where the call was made. But the approach in oops is that classes and objects are used to model real world entity taking help of methods which performs the functions.

    Procedure oriented programming - Gives importance to algorithm rather than data. It follows Top-down structures. Object oriented programming - Gives importance to data rather than algorithm. It follows Bottom-up structures.Every thing is viewed as an object.It includes features like data hiding polymorphism encapsulation and message passing.

    OOP supports classes objects and also1. Incapsulation - Wrap the data in single unit2. Inheritance - Aquire the properities of parent class3. Polymorphism - Same function can be used with different signatures

    Program based on C++

    Example 1 :Program based array of structureAns.

    #include#include#includestruct student{

    char name[20];int m;

    } s[5];

    void main(){

    int i,j,temp;char temp1[20];for(i=0;i

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    cout

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    #include#includevoid swap (char p, char q){

    char c ;c = p ;p = q ;q = c ;

    }

    void swap1 (char *p, char *q){

    char c ;c = *p ;*p = *q ;*q = c ;

    }

    void perm (char *a, int m, int n){

    if (m == n){ for (int i = 0 ; i < n ; i ++)

    cout

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    int *square ( int *a ) ;int i, *result ;clrscr () ;

    couti;result = square ( &i ) ;cout

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    cout

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    Example 8 : program to demonstrate function returning a StructureAns.

    #include #include struct student{

    int student_roll_no ;int marks_in_subject1 ;int marks_in_subject2 ;

    } ;void main (){

    struct student function () ;struct student t ;float result ;clrscr () ;t = function () ;cout

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    cout

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    } ;void main ( ){

    struct employee input ( ) ;struct employee e[5] ;int i, j, n ;clrscr ( ) ;

    coutn ;for ( i = 0; i < n; i++ )

    e[i] = input ( ) ;

    clrscr ( ) ;cout

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    Example 11 : Array of Students as a function argument

    #include #include struct student{

    int roll_no ;int physics_marks ;int chemistry_marks ;float average_marks ;

    } ;void main (){

    void find_average ( struct student a[] ) ;

    /* array of structure initialisation -- ( average_marks are initially set to 0 ) */struct student s[5] = { { 1, 50, 70, 0 },

    { 2, 67, 89, 0 },{ 3, 78, 87, 0 },{ 4, 56, 77, 0 },{ 5, 49, 45, 0 } } ;

    int i ;clrscr ();find_average ( s ) ;cout

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    a. list any four object oriented programming languages.Ans.Refer Q.No.

    b. Give syntax and example of defining structure and declaring structure variableAns.Refer Q.No.

    c. Give significance of & operator and * operator.Ans.Refer Q.No.

    Summer 2008a. Give Four characteristics of object oriented programmingAns.Refer Q.No.

    b. Which are input and output operator in C++. Give its exampleAns.Refer Q.No.

    c. Compare strcuture and classAns.Refer Q.No.

    Winter 2009a. Mention the concepts of OOPSAns.Refer Q.No.

    b. Distinguish between OOP and POProg.Ans.Refer Q.No.

    Summer 2009a. List any four features of procedure oriented language.Ans.Refer Q.No.

    b. List any four basic concepts of object oriented programming.Ans.Refer Q.No.

    c. Distinguish between procedure oriented and object oriented programmingAns.Refer Q.No.

    Winter 2009a. What is meant by object oriented programming language? Enlist any two object

    oriented programming languages.Ans.Refer Q.No.

    b. List application of oops technology.Ans.Refer Q.No.

    Summer 2010a. Define structure. Give syntax of defining structure.Ans.Refer Q.No.

    25

  • Prof.Manoj.Kavedia (9860174297) ([email protected])

    b.Explain an four features of object-oriented programming.Ans.Refer Q.No.

    26