CS201 Mid Term Solved Paper 2009 - 2

MIDTERM  EXAMINATION
Spring 2009
CS201- Introduction to Programming

Question No: 1      ( M a r k s: 1 ) http://vuzs.net
A precise sequence of steps to solve a problem is called
Statement
Program
Utility
Routine

Question No: 2      ( M a r k s: 1 ) http://vuzs.net
The Compiler of C language is written in
Java Language
UNIX
FORTRON Language
C Language

The C language is so powerful that the compiler of C and other various operating systems are written in C.
Question No: 3      ( M a r k s: 1 ) http://vuzs.net
Initialization of variable at the time of definition is,
Must
Necessary
Good Programming
None of the given options

Question No: 4      ( M a r k s: 1 ) http://vuzs.net
In if structure the block of statements is executed only,
When the condition is false
When it contain arithmetic operators
When it contain logical operators
When the condition is true

Question No: 5      ( M a r k s: 1 ) http://vuzs.net
Which of the following function(s) is/are included in stdlib.h header file?
double atof(const char *nptr)
int atoi(const char *nptr)
char *strcpy ( char *s1, const char *s2)
► 1 and 2 only

Question No: 6      ( M a r k s: 1 ) http://vuzs.net
Dealing with structures and functions passing  by reference is the most economical method
True
False


Question No: 7      ( M a r k s: 1 ) http://vuzs.net
Pointer is a variable which store,
Data
Memory Address
Data Type
Values

Question No: 8      ( M a r k s: 1 ) http://vuzs.net
Preprocessor program perform its function before ______ phase takes place.
Editing
Linking
Compiling
Loading

The C preprocessor modifies a source code file before handing it over to the compiler. You're most likely used to using the preprocessor to include files directly into other files,
Question No: 9      ( M a r k s: 1 ) http://vuzs.net
Which of the following can not be a variable name?
area
_area
10area
area2

Question No: 10      ( M a r k s: 1 ) http://vuzs.net
Which looping process is best, when the number of iterations is known?
for
while
do-while
all looping processes require that the iterations be known

Question No: 11      ( M a r k s: 1 ) http://vuzs.net
Which character is inserted at the end of string to indicate the end of string?
new line
tab
► null
carriage return
null character inserted at the end of the string by C automatically

 

Question No: 12      ( M a r k s: 1 ) http://vuzs.net
How many bytes are occupied by declaring following array of characters?
char str[] = “programming”;
10
11
12
13
11 plus one for null char (11+1= 12)

Question No: 13      ( M a r k s: 1 ) http://vuzs.net
Which of the following header file defines the rand() function?
iostream.h
conio.h
► stdlib.h
stdio.h

The function is rand() and is in the standard library. To access this function, we need to include <stdlib.h> library in our program. This function will return a random number. The number can be between 0 and 32767.
Question No: 14      ( M a r k s: 1 ) http://vuzs.net
Commenting the code _____________________
► Makes a program easy to understand for others.
Make programs heavy, i.e. more space is needed for executable.
Makes it difficult to compile
All of the given options.

Question No: 15      ( M a r k s: 1 ) http://vuzs.net
What's wrong with this for loop?
for (int k = 2, k <=12, k++)
the increment should always be ++k
the variable must always be the letter i when using a for loop
there should be a semicolon at the end of the statement
the commas should be semicolons

Question No: 16      ( M a r k s: 1 ) http://vuzs.net
For which array, the size of the array should be one more than the number of elements in an array?
int
double
float
► char

Question No: 17      ( M a r k s: 1 )
To Which category of the software “Compiler and Interpreter” belongs?
They belong to system software.
There are two type of system software
  1. Operating system
  2. Language translators.
These are part of language translators
Question No: 18      ( M a r k s: 1 )
What is the result of the expression x = 2 + 3 * 4 – 4 / 2
12
first multiplies 3*4 = 12 then Division  4/2 = 2
2+12-2 = 12
Question No: 19      ( M a r k s: 2 )
Write a declaration statement for an array of 10 elements of type float. Include an initialization statement of the first four elements to 1.0, 2.0, 3.0 and 4.0.
float tmp [10] = {1.0,2.0,3.0,4.0};
Question No: 20      ( M a r k s: 3 )
Write down the output of the following code?
int array[7], sum = 0;
for(int i=0;i<7;i++)
{
array[i] = i;
sum+= array[i];
}
cout<< “ Sum = “ <<sum;
answer: 21
Loop will run  times starts from zero and add values from 1 to 6 which is equal to 21



What will be the output of the following segment of C++ code?
int A[5] = {1 , 2, 3, 4};
int i;
for (i=0; i<5; i++)
{
A[i] = 2*A[i];
cout << A[i] << "  ";
}
2 4 6 8 0
Loops will run 5 times as its starting from zero. It will multiply the value of each item in array as last time is not initialized so it will multiply it with zero to give zero as output
Question No: 22      ( M a r k s: 10 )



Write a C++ program that will determine if a departmental store customer has exceeded the credit limit on a charge account.
Program should input the following facts in five variables
1. Account number
2. Balance at the beginning of month  (Beginning balance)
3. total of all items charged by customer this month  (charges)
4. total of all credits (credits)
5. allowed credit limit
Calculate the new balance
New balance = Beginning balance + charges – credits
Determine if new balance exceeds the allowed credit limit. For those customers whose credit limit is exceeded. The program should display the message “Credit Limit exceeded.”

Leave a Reply

Related Posts Plugin for WordPress, Blogger...