CS201 Mid Term Solved Paper 2010 - 1

MIDTERM  EXAMINATION
Spring 2010
CS201- Introduction to Programming

Question No: 1      ( M a r k s: 1 ) http://vuzs.net
In C/C++ the string constant is enclosed
In curly braces
In small braces
In single quotes
In double quotes
In fact, C's only truly built-in string-handling is that it allows us to use string constants (also called string literals) in our code. Whenever we write a string, enclosed in double quotes, C automatically creates an array of characters for us, containing that string, terminated by the \0 character. For example, we can declare and define an array of characters, and initialize it with a string constant:
               char string[] = "Hello, world!";
Question No: 2      ( M a r k s: 1 ) http://vuzs.net
For one byte there are _____ combinations of values that can be stored in computer.
26
27
28
24
Question No: 3      ( M a r k s: 1 ) http://vuzs.net
Switch statement deals with,
Integer data only
float data only
character data only
Integer and character data
Question No: 4      ( M a r k s: 1 ) http://vuzs.net
A record is a group of related _____________.
Files
Bytes
Fields
Data
Question No: 5      ( M a r k s: 1 ) http://vuzs.net
C++ views each file as a sequential stream of _______________.
Bytes
Bits
0’s or 1’s
Words
Question No: 6      ( M a r k s: 1 ) http://vuzs.net
To access the element of two dimensional array we use,
Single referencing
Single dereferencing
Double dereferencing
Double referencing
to access the elements of the two-dimensional array, we do double dereferencing like **multi'.
Question No: 7      ( M a r k s: 1 ) http://vuzs.net
If it is required to copy an array to another array then,
Both arrays must be of the same size and data type
Both arrays may be of different size
Both arrays may be of different data type
Both arrays may be of different size and type
Question No: 8      ( M a r k s: 1 ) http://vuzs.net
True
False
Postfix operators have the highest precedence .
(.) operator is post prefix variable so it has higher precedence over *
Question No: 9      ( M a r k s: 1 ) http://vuzs.net
Pointers works by pointing to a data type, which can be of the form,
Integer only
double only
character only
All of the given options
Question No: 10      ( M a r k s: 1 ) http://vuzs.net
Which of the following data type(s) can operate on modulus operator ‘%’?
float, int
float, double
int
char
There is a restriction in C language while using the modulus operator.
it can operator only on integers and cannot operate on floats or double
Question No: 11      ( M a r k s: 1 ) http://vuzs.net
What will be the output of following code?
int x = 10 ;
cout << “x =” << x ;
10
“x=10”
x=10
10=x
Question No: 12      ( M a r k s: 1 ) http://vuzs.net
Which looping process checks the test condition at the end of the loop?
for
while
do while
no looping process checks the test condition at the end
Question No: 13      ( M a r k s: 1 ) http://vuzs.net
What will be the correct syntax of the following statement?
ptr is a constant pointer to integer.
const int *ptr ;
const *int ptr ;
int const *ptr ;
int *const ptr ;
Question No: 14      ( M a r k s: 1 ) http://vuzs.net
A function must always return value.
True
False
Question No: 15      ( M a r k s: 1 ) http://vuzs.net
C is a/an ______ language
low level
object based
object oriented
function oriented
Question No: 16      ( M a r k s: 1 ) http://vuzs.net
Assignment operator is used for ___________.
calculation
reading
assigning value to variables
None of the given options.
Question No: 17      ( M a r k s: 2 )
What is the difference between switch statement and if statement.
ANSWER:
SWITCH:
The switch structure is  a multi selection construct that is used in multi way decision
IF:
If statement is computationally one of the most expensive statements in programe
Question No: 18      ( M a r k s: 2 )
What is wrong with following code and also give the reason of error?
int x , y ;
int *ptr1 = &x ;
int *ptr2 =&y ;
ptr1+ptr2 ;
Answer:
We need one more variable in which we put sum of ptr1 and ptr2 like
Int z;
z=ptr1+ptr2;
Question No: 19      ( M a r k s: 2 )
Which bit of the number is used as a sign bit?
Answer:
The most significant bit of the number is used as a sign bit (to denote the sign of the number).
Question No: 20      ( M a r k s: 3 )
What is the difference between tellg() and tellp() functions?
ANSWER:
tellg():function gives us the current get position of the file pointer. It returns a whole number of type long, which is the position of the next character to be read from that file.
tellp():
tellp() function is used to determine the next position to write a character while writing into a file. It also returns a long number
Question No: 21      ( M a r k s: 3 )
What is difference between variable and pointer?
Answer:
Variable:
Variables are used for easiness of program we put variable name and give some value and in later
variable names are used instead of value
Pointers:
But in pointers instead of passing variables(value) we pass their addresses and & is used to get the address.
Question No: 22      ( M a r k s: 5 )
What happened when we try to copy the array ‘arr1’ into the array ‘arr2’ in the following code segment, justify your answer?
main()
{
int arr1[3]={2,3,5}; 
int arr2[3];
arr2=arr1;
}
Answer:
We can not copy array directly in this way (arr2=arr1;) 
Each member of arr1 to be copied by each member of arr2.
We can use for loop to copy array 1 to array2
Question No: 23      ( M a r k s: 5 )
Differentiate between random access and sequential access file?
Answer:
Random access file:
Random access files are not in sequence mean its not necessary put that’s thing first that written first
we put any thing from file any where
So tellg() and tellp() are the two very useful functions while reading from or
writing into the files at some certain position.
Sequential access file:
Sequential access files are simple character files. while working with the
sequential access files we write in a sequence not in a random manner

Leave a Reply

Related Posts Plugin for WordPress, Blogger...