Tuesday, July 17, 2012

CS201 Programming Final Term Paper July 2012

My paper  16-07-2012.

Short questions 50% new thay.

Long questions men say jo mjhay yad hen wo yeh thay:



Ik while loop dia tha us ko for loop men change krna tha?

 Program likhna tha jis men “Welcome to Virtual University”  input krna tha phir is ki output is trah show krni thi

WELCOM

TO

VIRTUAL

UNIVERSITY

Yani k in letters ko upper case men convert bhi krna tha aur space ki jaga endl dal kr letters ko ilehda bhi krna tha.

\

Ik matrix 3x4 bnana tha us min 12345678 yeh integer show krnay thy

Out put yeh deni thi      1   2   3   4

                                            5    6   7   8

Keybord say input leni thi as a array.



Q4: What is the output of following code snippet.  (2)

 // class templates
 #include <iostream>
 using namespace std;

 template <class T>
 class mypair {
 T a, b;
 public:
 mypair (T first, T second)
 {a=first; b=second;}
 T getmax ();
 };

 template <class T>
 T mypair<T>::getmax ()
 {
 T retval;
 retval = a>b? a : b;
 return retval;
 }
 int main () {
 mypair <int> myobject (100, 75);
 cout myobject.getmax();
 system("pause");
 }



Question No: 33 ( Marks: 3 )

What happens when we use new and delete operator?

Answer:

When we use new operator to create objects the memory space is allocated for the object and then its constructor

is called. Similarly, when we use delete operator with our objects, the destructor is called for the object before

deallocating the storage to the object.

Question No: 16      ( Marks: 1 ) - Please choose one





Which of the following function call is correct for the function prototype?

defaultParameters ( int a, int b = 7, char z = ‘*’ );





       ► defaultParameters (5);





       ► defaultParameters (5, ‘8’);





       ► defaultParameters (6, ‘#’);





       ► defaultParameters (0, 0, ‘*’, 0);

Question No: 17      ( Marks: 1 ) - Please choose one



When an operator function is defined as member function for a binary Plus (+) operator then the number of argument it take is/are.





       ► Zero



       ► One



       ► Two



       ► N arguments

Question No: 23      ( Marks: 1 ) - Please choose one





NULL value has been defined in ______ and _________ header files.





       ► strings.h and iostream.h





       ► ctype.h and conio.c





       ► conio.c and conio.h





       ► stdlib.h and stddef.h









Q. Suppose a program has a math class having only one data member number.

Write the declaration and definition of operator function to overload + operator for the statements of main function.

         math obj1, obj2;

         obj2= 10 + obj1  ; 

Ans:

#include <iostream.h>

math

{

mth operator + (obj1,obj2)

mth operator + (obj1,obj2)

{

 mth operator + (obj1,obj2)

mth operator + (obj1,obj2)



}

}

0 comments:

Followers

Copyright VirtualHelp 2011. Powered by Blogger.

Blog Archive

Search Your Subject