Spring Cs 201
Spring Cs 201
Spring 2009
CS201- Introduction to Programming
Time: 120 min
Marks: 75
Marks
Q No. 9 10 11 12 13 14 15 16
Marks
Q No. 17 18 19 20 21 22 23 24
Marks
Q No. 25 26 27 28 29 30 31 32
Marks
Q No. 33 34 35 36 37 38 39 40
Marks
Q No. 41
Marks
Question No: 1 ( Marks: 1 ) - Please choose one
► Single referencing
► Single dereferencing
► Double dereferencing
► Double referencing
► True
► False
► #error
► #define
► #line
► #ndefine
► True
► False
► True
► False
We can change the artiy (Number of operands required) of an operator through operator
overloading
► True
► False
► True
► False
► True
► False
► True
► False
The insertion (<<) and extraction (>>) operators are unary operators.
► True
► False
What will be the correct syntax for the following function call?
► square (&num);
► square (num);
► square (*num);
Question No: 13 ( Marks: 1 ) - Please choose one
char *x = ”programming” ;
cout << *(x+2) << *(x+3) << *(x+5) << *(x+8) ;
► ogai
► ramg
► prgm
► rorm
When an operator function is define as member function then operand on the left side of
operator must be an object.
► True
► False
► Binary operators
► Unary operators
► Logical operators
► Conditional operators
► JAVA
►B
►C
► FORTRAN
► Signed integer
► Un-signed integer
► Signed double
► Un-signed double
► Pointers
► Array index
Which of the following is the correct C++ syntax to allocate space dynamically for an
array of 10 int?
► new int(10) ;
► new int[10] ;
► int new(10) ;
► int new[10];
Which of the following will be the correct function call for function prototype given
below?
int func (int &);
► func(int num);
► func(&num);
► func(num);
► func(*num);
For non-member operator function, object on left side of the operator may be
Which of the following object(s) will call the member operator function within the
statement given below?
obj1=obj2+obj3;
► Object obj1
► Object obj2
► Object obj3
► shared by objects
Which of the following is used for allocating space for static variables?
► Heap
► Free store
► Stack
► function prototype
► function definition
► syntax error
► logical error
► not an error
► True
► False
► any where
► in start
► at the end
► logical expressions
► arithmetic expressions
What will be the output of following function if we call this function by passing int 5?
Let suppose Pakistan Meteorological Department ask you to develop a simple program ,
in which you have to show the humidity and temperature. To achieve the result you
create two classes Humidity and Temperature both having PrintWeather( , ) as non
member function for displaying the result and their respective data members.
Output:
The temperature is 20
And the humidity is 15
Note: Function overriding is not allowed.
Write a program which has a class Date, This class should have four data members, day,
month, year, firstday (i.e. first day of the month).
The class should further contain two constructors (i.e. Default and parameterize), a
Display Function which display the date in format ( e.g 10-01-2007) and - - Operator
function, which decrement the day member of the Date class. Keep in mind that if the
day is first day of the month then it should also decrement the month data member and if
month is the first month of the year then it should also decrement the year data member
of the class.
In main function define an object of the Date class and decrement it 1 time.