0 évaluation0% ont trouvé ce document utile (0 vote)
150 vues10 pages
What is difference between getch() and getche()? 14.what is use of setw() manipulator? 15.what is difference between typedef and enum. 16.what is difference? between a reference and pointer? 17.what is the size of int,char,long,long double,float data type? 18.what will be the output for the following: int a=5,b=7; if(a=5) cout"False"; else cout cout
What is difference between getch() and getche()? 14.what is use of setw() manipulator? 15.what is difference between typedef and enum. 16.what is difference? between a reference and pointer? 17.what is the size of int,char,long,long double,float data type? 18.what will be the output for the following: int a=5,b=7; if(a=5) cout"False"; else cout cout
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme DOC, PDF, TXT ou lisez en ligne sur Scribd
What is difference between getch() and getche()? 14.what is use of setw() manipulator? 15.what is difference between typedef and enum. 16.what is difference? between a reference and pointer? 17.what is the size of int,char,long,long double,float data type? 18.what will be the output for the following: int a=5,b=7; if(a=5) cout"False"; else cout cout
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme DOC, PDF, TXT ou lisez en ligne sur Scribd
2. Differentiate between Break and continue. 3. For which statements does it make sense to use label? [Hint- The only statements for which it makes sense to use a label are those statements that can enclose a break or continue statement. ] 4. How can you make a function call if you need to change more than one value using a function, When a function can only return one value. 5. What is the use of static variables? 6. What are extern variables, register variables? 7. What is difference between getch() and getche()? 8. what is use of setw() manipulator? 9. What is cascading? 10.what is sizeof int,char,long,long double,float data type? 11.What is difference between a reference and pointer? 12.What are enumerators? 13.Which data type occupies more space struct or union? 14.Which data type is faster register or int , int or float? 15.what is difference between typedef and enum. 16.what is macro? 17.what is difference between a constant value and constant datatype ? 18.what is the size of unsigned char str[40]? 19.what will be the output for the following: int a=5; if(a=7) cout<<”False”; else cout<<”True”; 20. what will be the output for the following: int a=6,b=7; cout<<a++<<++b<<a+b++; 21. Explain ?:: ternary operator. 22.What is type casting? What do you understand by explicit and implicit type casting? 23.Can you use switch to check equality for float values. 24.unsigned float a; Is this correct statement? 25.How one can come out from a infinite loop? 26.What is empty loop? 27.Can you compare inequalities condition using switch? 28.what is difference between goto and gotoxy()? 29.gotoxy(8,19) ; Explain the statement. 30.what is difference between exit(1) and exit(0)? 31.What is difference between return,exit and break ? 32.Can you skip any part in for loop? 33. How many ; are must in a for loop? 34.What is difference between break and continue? 35.What is true loop? 36.What is difference between strcpy() and strncpy()? 37.Explain atoi() and atol() function? 38.An index value can have only a constant value or constant variable. T/F? 39.What is difference between user defined and predefined functions? 40.What is difference between a parameter and an argument? 41.What is difference between actual parameter and formal parameter? 42.What is difference between global variable and local variable? 43.Give the uses of Scope Resolution operator. {Hint - 3 uses] 44.Give the uses of * operator. 45.what is function prototype? 46.How can you calculate the remainder of two float variables? 47.What is limitation of % operator? 48.What is difference between delay() and sleep()? 49.What is the use of randomize() function? 50.What is difference between rand() and srand() function? 51.What are possible values generated : R = random(20)+random(2) 52.what is difference between clreol() and clrscr()? 53.What is recursive function? 54.Function calls uses which data structure Stack/Queue? 55.Commands given for printout are stored uses STACK/QUEUE. 56.Comment: C++ "includes" behavior . 57.. What is the use of Operator Overloading. 58. Every object has : state, behavior and identity - explain . 59. What is the output of printf("%d") 60.What are jump Statements? Classes & Objects
Constructors And Destructors
1. Why constructors have no return type? 2. Why destructors invoke in reverse order? 3. What is role of constructor? 4. Why we need constructors? 5. What property of OOP is implemented in Constructors? 6. Can destructors be overloaded Yes/No & Why? 7. Can constructors be overloaded Yes/No & Why? 8. What is difference between default constructor and constructor with default arguments? 9. Can constructor use static variables? 10.Does any value is returned by Constructors? 11.Why the reference of an object is passed in copy constructor? 12.When copy constructor is invoked? 13.From the given conditions (1) Sample S1=S2; (2) S1=S2 ; When copy constructor will invoke. 14.if a derived class has no parameters for its constructor but a base class has parameterized constructor , how the constructor for the derived class would defined? 15. Copy constructors are called in following cases: a) when a function returns an object of that class by value b) when the object of that class is passed by value as an argument to a function c) when you construct an object based on another object of the same class d) When compiler generates a temporary object 16. Difference between Deep Copy and Shallow Copy ? Deep copy involves using the contents of one object to create another instance of the same class. In a deep copy, the two objects may contain ht same information but the target object will have its own buffers and resources. the destruction of either object will not affect the remaining object. The overloaded assignment operator would create a deep copy of objects. Shallow copy involves copying the contents of one object into another instance of the same class thus creating a mirror image. Owing to straight copying of references and pointers, the two objects will share the same externally contained contents of the other object to be unpredictable. 17. Using a copy constructor we simply copy the data values member by member. This method of copying is called shallow copy. If the object is a simple class, comprised of built in types and no pointers this would be acceptable. This function would use the values and the objects and its behavior would not be altered with a shallow copy, only the addresses of pointers that are members are copied and not the value the address is pointing to. The data values of the object would then be inadvertently altered by the function. When the function goes out of scope, the copy of the object with all its data is popped off the stack. If the object has any pointers a deep copy needs to be executed. With the deep copy of an object, memory is allocated for the object in free store and the elements pointed to are copied. A deep copy is used for objects that are returned from a function. 18. Diff. bet. While and Do-while A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once. 19. Diff. bet. Break and continue A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement. 20. 21. For which statements does it make sense to use label? 22. The only statements for which it makes sense to use a label are those statements that can enclose a break or continue statement. 23. A class does not inherit constructors from any of its super classes. 24. Difference between C structure and C++ Structures: 25. C++ places greater emphasis on type checking, compiler can diagnose every diff between C and C++ 26. 1. structures are a way of storing many different values in variables of potentially diff types under under the same name 2. classes and structures make program modular, easier to modify make things compact 3. useful when a lot of data needs to be grouped together 4. struct Tag {?}struct example {Int x;}example ex; ex.x = 33; //accessing variable of structure 5. members of a struct in C are by default public, in C++ private 6. unions like structs except they share memory ? allocates largest data type in memory - like a giant storage: store one small OR one large but never both at the same time 7. pointers can point to struct: 8. C++ can use class instead of struct (almost the same thing) - difference: C++ classes can include functions as members 9. members can be declared as: private: members of a class are accessible only from other members of their same class; protected: members are accessible from members of their same class and friend classes and also members of their derived classes; public: members are accessible from anywhere the class is visible 10. structs usually used for data only structures, classes for classes that have procedures and member functions 11. use private because in large projects important that values not be modified in an unexpected way from the POV of the object 12. advantage of class declare several diff objects from it, each object of Rect has its own variable x, y AND its own functions 13. concept of OO programming: data and functions are properties of the object instead of the usual view of objects as function parameters in structured programming 27. 28. 29. Q1. Differentiate between a run-time error and syntax error. Give one example of each. [Hint : Logic & Syntax] Q. 2. Differentaite between a data type struct and a data type class in C++. What is the need for a constructor function in an object. [Hint : Structures & Classes] Q. 3. Is it possible to apply Binary Search for any sorted data? Justify. [Hint : Yes] Q. 4. Differentiate between a LIFO list and FIFO list. [Hint : Stacks & Queues] Q. 5. Write any two differences between Procedural Programming and Object Oriented Programming. [Hint :C & C++] Q. 6. What is a pointer? [Hint : Address variable] Q. 7. What is a Queue? [Hint : LIFO] Q. 8. What is the purpose of comments and indentation in a program? [Hint : Remark] Q. 9. List four built-in data types available in C++. [Hint : Data Types] Q. 10. Why arrays are called static data structure? [Hint : Arrays & Data Types] Q. 11. Distinguish between serial file and a sequential file. [Hint : File Handling] Q. 12. What do you mean by Inheritence? [Hint : Classes & Derived Classes] Q. 13. What are constructors & destructors. What purpose do they serve. [Hint : Class Functions] Q. 14. Distinguish between an object and a class. [Hint : Variables & Data Types] Q. 15. What is the pre-condition for Binary Search to be performed on a single dimensional array? [Hint : sorting] Q. 16. Differentiate between a Character constant and a string literal or constant. [Hint : String] Q . 17. Differentiate between the privately & publicly derived visibility modes. Q. 18. What is meant by linear data structure? [Hint : Serial Data] Q. 19. What is a Deque? [Hint : Data Structures] Q.21. What is a copy constructor? [Hint : Member Function] Q.22. Define the term sorting and searching. [Hint : Arrays] Q. 23. Differentiate between static data structure & dynamic structure. [Hint : Data Types] Q. 24. Define the following terms: Inheritance & Encapsulation. [Hint : OOP] Q. 25. What is a copy constructor. What do you understand by constructor overloading. [Hint : Function Overloading] Q. 26. Write two major differences between Object Oriented Programming and Procedural Programming. Q. 27. What do you understand by constructor and destructor functions used in classes ? How are these functions different from other member functions. Q. 28. Differentiate between ifstream class and ofstream class. [Hint : Reading/Writing] Q. 29. Why main function is special. Give two reasons. [Hint : Program instructions] Q. 30. What do you understand by visibility modes in class derivations ? What are these modes? [Hint : Public, Private & Protected] Q. 31. Differentiate between read( ) & write( ) functions. [Hint : Read & Write records- block of data] Q. 32. Write two advantages of using include compiler directive. [Hint : Header Files] Q. 33. What do you understand by default constructor and copy constructor functions used in classes? How are these functions different from normal constructors? [Hint : Member functions] Q. 34. Differentiate between getline( ) & getc( ) functions. [Hint : String input] Q. 35. Illustrate the concept of Function Overloading with the help of an example. [Hint : Multiple Methods] Q.36. Illustrate the use of the this pointer with the help of an example. [Hint : Classes & Objects] Q. 37. Encapsulation is one of the major properties of OOP. How is it implemented in C++. [Hint : OOP features] Q. 38. Illustrate the use of “Self Referential Structures” with the help of an example. Q. 39. Reusability of classes is one of the major properties of OOP. How is it implemented in C++. [Hint : Objecters & Classes] Q .40. Distinguish between: int*ptr=new int(5); & int * ptr= new int[5]; [Hint : Pointers & Array] Q .41. Distinguish between ios::out & ios::app. [Hint : File output/Append] Q. 42. What is the purpose of Header file in a program? [Hint : Include functions] Q. 43. What do you understand by a Base Class and a Derived Class. If a base class and a derived class each include a member function with the same name and arguments, which member function will be called by the object of the derived class if the scope operator is not used. Q. 44. Illustrate the concept of Inheritance with the help of an example. Q. 45. What is the difference between put( ) and write( ). Q. 46. Will a C compiler always compile C++ code? [Hint : NO] Q. 47. Which is not a valid keyword: public, protected, guarded ? [Hint : ‘g’] Q. 48. What is the correct syntax for inheritance a. class aclass : public superclass b. class aclass inherit superclass c. class aclass <-superclass [Hint : (a)] Q. 49. What does the following do: for(;;) ; [Hint : loop] Q. 50. Of the numbers 12 23 9 28 which would be at the top of a properly implemented maxheap? [Hint : Arrays] Q. 51. What does the break; do in the following? void afunction() { if(1) { break; a_function(); cout<<“Err”; } } [Hint : Breaks loop] Q. 52. What are pointers, when declared, initialized to? [Hint : Variable address] Q. 53. What is the last index number in an array of 100 characters? Q. 54. Would you rather wait for selection sort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) [Hint : Dry Run] Q. 55. What does the following algorithm do? set sum to zero. set i to 1. input n. while i is less than or equal to n do { add i to sum. increment i. } output sum. Q.55. What would be output if the value entered for n was 0? What would be the effect of reversing the order of the statements in the loop body on the general result produced by the algorithm? [Hint : Dry Run] Q. 56. If an array has a 100 elements what is the allowable range of subscripts? [Hint : Array option base] Q. 57. What is the difference between the expressions a4 and a[4]? [Hint : Variable & Arrary] Q. 58. Write a declaration for a 100 element array of floats. Include an initialisation of the first four elements to 1.0, 2.0, 3.0 and 4.0. [Hint : Array initialialion of arrays] Q. 59. Evaluate !(1&&5||1&&0) [Hint : Logical Condition] Q. 60. What would be output by the following section of C++? int A[5] = {1 , 2, 3, 4}; int i; for (i=0; i<5; i++) { A[i] = 2*A[i]; cout << A[i] << “ “; } [Hint : Dry Run] Q. 61. What is wrong with the following section of program? int A[10], i; for (i=1; i<=10; i++) cin >> A[i]; [Hint : Dry run] Q. 62. Write a function heading for a function which will double the first n elements of an array. If the function was amended so that it would return false if n was larger than the size of the array how should the function heading be written? If the function was to be changed so that a new array was produced each of whose elements were double those of the input array how would the heading be written? [Hint : Function definition] Q. 63. What does the following do: void afunction(int *x) { x=new int; *x=12; } int main() { int v=10; afunction(&v); cout<<v; } (a) Outputs 12 (b) Outputs 10 (c) Outputs the address of v [Hint : Dry Run] Q. 64. What do nonglobal variables default to: a. auto b register c. static [Hint : Variable declaration] Q. 65. Which header file allows file i/o with streams? a. iostream.h b. fstream.h c.fileio.h [Hint : File stream] Q. 66. What is the outcome of cout<<abs(-16.5); a. 16 b. 17 c.16.5 [Hint : Dry run] Q. 67. What will strcmp(“Astring”, “Astring”); return? [Hint : String compare] Q. 68. Evaluate !(1&&1||1&&0) [Hint : Logical Condition] Q. 69. What header file is needed for exit(); [Hint : Process] Q. 70. What ANSI C++ function clears the screen? [Hint : Clrscr]