OOP with C by E Balagurusamy gt Solution

Oop With C By E Balagurusamy Gt Solution-PDF Download

  • Date:26 Jan 2020
  • Views:41
  • Downloads:0
  • Pages:183
  • Size:920.17 KB

Share Pdf : Oop With C By E Balagurusamy Gt Solution

Download and Preview : Oop With C By E Balagurusamy Gt Solution

Report CopyRight/DMCA Form For : Oop With C By E Balagurusamy Gt Solution


a Emphasis is on doing things algorithms, b Large programs are divided into small programs known as function. c Most of the function share global data, d Data move openly around the system from function to function. e Function transform data from one form to another. 1 4 Discuss an approach to the development of procedure oriented programs. Ans In the procedure oriented approach the problem is viewed as a sequence of things to be. done such as,2 Calculating,3 Printing, A number of functions are written to accomplish these tasks. 1 5 Describe how data are shared by functions in a procedure oriented program. Ans In a multi function 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. 1 6 What is object oriented programming How is it different from the procedure oriented. programming, Ans Object oriented programming OOP 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 creation copies of such modules on demand. Different between OOP Object oriented programming POP Procedure oriented programming. 1 OOP has data hading feature for which the data of a class cannot be accessed by the member. function of other class but POP has no such feature. 2 In OOP we can design our own data type which is same as built in data type But in POP we. can not do this, 1 7 How are data and functions organized in an object oriented program.
Ans Data and functions are belongs to a class Data is called data member and functions are. called member functions There is a visibility mode such as public and private Generally data is. private and functions are public, 1 8 What are the unique advantages of an object oriented programming paradigm. Ans The unique advantage of object oriented program paradigm is to have a working definition. of OOP before we proceed further,1 9 Distinguish between the following terms. a Objects and classes,b Data abstraction and data encapsulation. c Inheritance and polymorphism,d Dynamic binding and message passing. Ans a Objects are the basic run time entities which contain data and code to manipulate data. where the entire set of data and code of an object can be made as a user defined data type with the. help of a class In short objects are numbers of classes. b Describing the functionality of a class independent of its implementation is called data. abstraction Where data encapsulation means the wrapping up of data and functions into a single. c The mechanism of deriving a new class from an old one is called inheritance where. polymorphism means one thing with several distinct terms. d Binding refers to the linking of a procedure call to be executed in response to the call When. binding occurs at run time then it is known as dynamic binding. Massage passing involves specifying the name of the object the name of the function and the. information to be sent, 1 10 What kinds of things can become objects in 00P.
Ans Objects are the basic run time entities in an object oriented system They may represent a. person a place a bank account a table of data or any item that the program has to handle. 1 11 Describe inheritance as applied to OOP, Ans Inheritance is one of the most powerful feature of object oriented programming Inheritance. is the process of creating new class from existing class The new class is called derived class and. existing class is called base class, 1 12 What do you mean by dynamic binding How is it useful in OOP. Ans Binding refers to the linking of a procedure call to be executed in response to the call When. binding occurs at run time it is known as dynamic binding Dynamic binding is useful in OOP. such as a function call associated with a polymorphic reference depends on the dynamic type of. that reference, 1 13 Now does object oriented approach differ from object based approach. Ans Object based programming do not support inheritance and dynamic binding but object. oriented programming do so, 1 14 List a few areas of application of 001 technology. Ans Areas of application of OOP technology are,1 Real time system.
2 Simulation and modeling,3 Object oriented database. 4 Hypertext hypermedia,5 Decision support and office automation system. 1 15 State whether the following statements are TRUE or FALSE. a In procedure oriented programming all data are shared by all functions. b The main emphasis of procedure oriented programming is on algorithms rather than on data. c One of the striking features of object oriented programming is the division of programs into. objects that represent real world entities, d Wrapping up of data of different types into a single unit is known as encapsulation. e One problem with 00P is that once a class is created it can never be changed. f Inheritance means the ability to reuse the data values of one object by. g Polymorphism is extensively used in implementing inheritance. h Object oriented programs are executed much faster than conventional programs. i Object oriented systems can scale up better from small to large. j Object oriented approach cannot be used to create databases. Review Questions, 2 1 State whether the following statements are TRUE or FALSE. a Since C is a subset of C all C peograms will run under C compilers. b In C a function contained within a class is called a member function. c Looking at one or two lines of code we can easily recognize whether a program is written in. d In C it is very easy to add new features to the existing structure of an object. e The concept of using one operator for different purposes is known as aerator overloading 10. The output function printfl cannot be used in C programs. most lines of codes are the same in C C, 2 2 Why do we need the preprocessor directive include iostream.
Ans include iostream directive causes the preprocessor to add the contents of iostream file. to the program, 2 3 How does a main function in C differ from main in C. Ans In C main by default returns the void type but in C it returns integer by default. 2 4 What do you think is the main advantage of the comment in C as compared to the old C. type comment,Ans is more easy and time saving than. 2 5 Describe the major parts of a C program,Ans Major parts of a C program. 1 Include files,2 Class declaration,3 Member function definitions. 4 Main function program,Debugging Exercises,2 1 Identify the error in the following program.
include iostream h,comment i i 1,Ans Syntax error comment i i 1. 2 2 Identify the error in the following program,include iostream h. short i 2500 j 3000,cour i j i j,Ans cout i j Illegal structure operation i j. 2 3 What will happen when you run the following program. include iostream h,int i 10 j 5,int modResult 0,int divResult 0. modResult i j,cout modResult,divResult i modResult.
cout divResult, Ans floating point Error or divide by zero divResult i modResult. Note If this kind of Error exist in a program the program will successfully compile but it will. show Run Error, 2 4 Find errors if any in the following C statements. a cout x x b m 5 n 10 m n c cin x y,d cout h Name name. e cout Enter value cin x,f Addition z x y,Error Correction. A Statement missing cout x x,B No error,C Expression syntax error cin x y.
Illigal character,Statement missing,E No error,F No error. Programming Exercises, 2 1 Write a program to display the following output using a single cout statement. Physics 77,Chemistry 69,1 include iostream h,2 include iomanip h. 3 int main,6 char sub Maths Physics Chemestry,7 int mark 90 77 69. 8 for int i 0 i 3 i,10cout setw 10 sub i setw 3 setw 4 mark i endl.
12 return 0,Physics 77,Chemistry 69, 2 2 Write a program to read two numbers from the keyboard and display the larger value. on the screen,1 include iostream h,2 include iomanip h. 4 int main,6 float a b,7 cout Enter two values endl. 10 cout larger value a endl,12 cout larger value b endl. 13 return 0,Enter two values 10 20,larger value 20.
2 3 Write a program to input an integer from the keyboard and display on the screen. WELL DONE that many times,1 Solution,2 include iostream h. 3 include iomanip h,4 int main,7 char str,8 str WELL DONE. 9 cout Enter an integer value,11 for int i 0 i n i. 13 cout str endl,15 return 0,Enter an integer value 5. 2 4 Write a program to read the values a b and c and display x where. Test the program for the following values,a a 250 b 85 c 25.
b a 300 b 70 c 70,1 include iostream h,2 include iomanip h. 3 int main,5 float a b c x,6 cout Enter the value of a b c endl. 7 cin a b c,8 if b c 0,10 x a b c,11 cout x a b c x endl. 15 cout x infinity endl,17 return 0,During First Run. Enter the value of a b c 250 85 25,x a b c 4 166667.
During Second Run,Enter the value of a b c 300 70 70. x infinity, 2 5 Write a C program that will ask for a temperature in Fahrenheit and display it in. 1 include iostream h,2 include iomanip h,4 int main. 6 float f theta,7 cout Enter the temperature in Feranhite scale. 9 theta f 32 9 5,10 cout Temperature in Celsius theta endl.
11 return 0,Enter the temperature in Feranhite scale 105. Temperature in Celsius 40 555557, 2 6 Redo Exercise 2 5 using a class called temp and member functions. 1 include iostream h,2 include iomanip h,4 class temp. 6 float f theta,8 float conversion float f,11float temp conversion float f. 13 theta f 32 9 5,14 return theta,16int main,19 float f.
20 cout Enter temperature in Farenheite scale endl. 22 cout Temperature in Celsius scale t conversion f endl. 23 return 0,Enter the temperature in Feranhite scale 112. Temperature in Celsius 44 444443,Review Questions, 3 1 Enumerate the rules of naming variables in C How do they differ from ANSI C rules. Ans Rules of naming variables in C are given below. a Any character from a to z or A to Z can be used,b Digit can be used but not at the beginning. c Underscore can be used but space is not permitted. d A keyword cannot be used as variable name, In C a variable can be declared any where in the program but before the using of the variable. In C all variables must be declared at the beginning of the program. 3 2 An unsigned int can be twice as large as the signed int Explain how. In case of unsigned int the range of the input value is 0 to 2m 1 where m is no of bit. In case of signed int the range of the input value is 2m 1 to 2m 1 1. So maximum value for unsigned int can be twice as large as the signed int. Here the absolute value of lower value 2m 1 for signed int must be considered for finding. average value of signed int,3 3 Why does C have type modifiers.
Ans To serve the needs of various situation, 3 4 What are the applications of void data type in C. Ans Two normal uses of void are, 1 to specify the return type of a function when it is not returning any value. 2 To indicate any empty argument list to a function. Example void function void, Another interesting use of void is in the declaration of generic pointers. void gp gp is generic pointer, A pointer value of any basic data type can be assigned to a generic pointer. gp ip valid, 3 5 Can we assign a void pointer to an int type pointer If not why Now can we achieve.
Ans We cannot assign a void pointer to an int type pointer directly Because to assign a pointer. to another pointer data type must be matched We can achieve this using casting. 3 6 Describe with examples the uses of enumeration data types. Ans An enumerated data type is a user defined type It provides a way for attaching names to. numbers in ANSIC,enum kuet EEE CSE ECE CE ME IEM,The enum keyword automatically enumerates. In C each enumerated data type retains its own separate type. 3 7 Describe the differences in the implementation of enum data type in ANSI C and C. Ans Consider the following example,enum kuet EEE CSE ECE CE ME IEM. Here kuet is tag name, In C tag name become new type name We can declare a new variables Example. kuet student,ANSI C defines the types of enum to be int. In C int value can be automatically converted to on enum value But in C this is not permitted. student cgp 3 01 Error in C,student cgp student 3 01 OK in C.
3 8 Why is an army called a derived data type, Ans Derived data types are the data types which are derived from the fundamental data types. Arrays refer to a list of finite number of same data types The data can be accessed by an index. number from o to n Hence an array is derived from the basic date type so array is called derived. 3 9 The size of a char array that is declared to store a string should be one larger than the. number of characters in the string Why, Ans An additional null character must assign at the end of the string that s why the size of char. array that is declared to store a string should be one larger than the number of characters in the. 3 10 The const was taken from C and incorporated in ANSI C although quite differently. Ans In both C and C any value declared as const cannot be modified by the program in any. way However there are some differences in implementation In C. OOP with C by E Balagurusamy gt Solution Chapter 1 Review Questions 1 1 What do you think are the major issues facing the software industry today Ans Many software products are either not finished or not used or not delivered for some major errors Today some of the quality issues that must be considered for software industry are

Related Books