Education In Pakistan

Papers, Notes, Books & Help For Students

UPDATED EDUCATIONAL NEWS INTERVIEW HELP FOR ALL JOBS ONLINE BOOKS SCHOLARSHIPS AVAILABLE INTERNSHIP JOBS

Tag: VU. CS201- .Introduction. to. Programming. MIDTERM. EXAMINATION. Spring. 2009

VU CS201- Introduction to Programming MIDTERM EXAMINATION Spring 2009

.

MIDTERM EXAMINATION

Spring 2009

CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) – Please choose one

A precise sequence of steps to solve a problem is called

Statement

► Program

Utility

Routine

Question No: 2 ( Marks: 1 ) – Please choose one

The Compiler of C language is written in

Java Language

► UNIX

FORTRON Language

C Language

Question No: 3 ( Marks: 1 ) – Please choose one

Initialization of variable at the time of definition is,

► Must

Necessary

.

Good Programming

None of the given options

Question No: 4 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 ) – Please choose one

Dealing with structures and functions passing by reference is the most economical method

► True

False

.

Question No: 7 ( Marks: 1 ) – Please choose one

Pointer is a variable which store,

Data

► Memory Address

Data Type

Values

Question No: 8 ( Marks: 1 ) – Please choose one

Preprocessor program perform its function before ______ phase takes place.

Editing

Linking

► Compiling

Loading

Question No: 9 ( Marks: 1 ) – Please choose one

Which of the following can not be a variable name?

area

► _area

10area

area2

.

Question No: 10 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 ) – Please choose one

Which character is inserted at the end of string to indicate the end of string?

new line

tab

► null

carriage return

Question No: 12 ( Marks: 1 ) – Please choose one

How many bytes are occupied by declaring following array of characters?

char str[] = “programming”;

10

.

11

► 12

13

Question No: 13 ( Marks: 1 ) – Please choose one

Which of the following header file defines the rand() function?

iostream.h

conio.h

► stdlib.h

stdio.h

Question No: 14 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 ) – Please choose one

.

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 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 )

To Which category of the software “Compiler and Interpreter” belongs?

Question No: 18 ( Marks: 1 )

.

What is the result of the expression x = 2 + 3 * 4 – 4 / 2

Question No: 19 ( Marks: 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.

Question No: 20 ( Marks: 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;

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] << ” “;

}

Question No: 22 ( Marks: 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.”

VU CS201- Introduction to Programming MIDTERM EXAMINATION Spring 2009

.

MIDTERM EXAMINATION

Spring 2009

CS201- Introduction to Programming

Question No: 1 ( Marks: 1 ) – Please choose one

A precise sequence of steps to solve a problem is called

Statement

► Program

Utility

Routine

Question No: 2 ( Marks: 1 ) – Please choose one

The Compiler of C language is written in

Java Language

► UNIX

FORTRON Language

C Language

Question No: 3 ( Marks: 1 ) – Please choose one

Initialization of variable at the time of definition is,

► Must

Necessary

.

Good Programming

None of the given options

Question No: 4 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 ) – Please choose one

Dealing with structures and functions passing by reference is the most economical method

► True

.

False

Question No: 7 ( Marks: 1 ) – Please choose one

Pointer is a variable which store,

Data

► Memory Address

Data Type

Values

Question No: 8 ( Marks: 1 ) – Please choose one

Preprocessor program perform its function before ______ phase takes place.

Editing

Linking

► Compiling

Loading

Question No: 9 ( Marks: 1 ) – Please choose one

Which of the following can not be a variable name?

area

► _area

10area

area2

.

Question No: 10 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 ) – Please choose one

Which character is inserted at the end of string to indicate the end of string?

new line

tab

► null

carriage return

Question No: 12 ( Marks: 1 ) – Please choose one

How many bytes are occupied by declaring following array of characters?

char str[] = “programming”;

10

.

11

► 12

13

Question No: 13 ( Marks: 1 ) – Please choose one

Which of the following header file defines the rand() function?

iostream.h

conio.h

► stdlib.h

stdio.h

Question No: 14 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 ) – Please choose one

.

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 ( Marks: 1 ) – Please choose one

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 ( Marks: 1 )

To Which category of the software “Compiler and Interpreter” belongs?

Question No: 18 ( Marks: 1 )

.

What is the result of the expression x = 2 + 3 * 4 – 4 / 2

Question No: 19 ( Marks: 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.

Question No: 20 ( Marks: 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;

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] << ” “;

}

Question No: 22 ( Marks: 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.”

VU CS201- Introduction to Programming MIDTERM EXAMINATION Spring 2009

.

MIDTERM EXAMINATION

Spring 2009

CS201- Introduction to Programming

Ref No: 440120

Time: 60 min

Marks: 38

Student Info

Student ID:

Center: OPKST

Exam Date:

For Teacher’s Use Only

Q No. 1 2 3 4 5 6 7 8 Total

Marks

Q No. 9 10 11 12 13 14 15 16

Marks

Q No. 17 18 19 20 21 22

Marks

.

Question No: 1 ( Marks: 1 ) – Please choose one

The function of cin is

To display message

► To read data from keyboard

To display output on the screen

To send data to printer

Question No: 2 ( Marks: 1 ) – Please choose one

In C/C++ language the header file which is used to perform useful task and manipulation

of character data is

cplext.h

► ctype.h

stdio.h

delay.h

Question No: 3 ( Marks: 1 ) – Please choose one

How many parameter(s) function getline() takes?

0

1

2

.

3

Question No: 4 ( Marks: 1 ) – Please choose one

Word processor is

Operating system

► Application software

Device driver

Utility software

Question No: 5 ( Marks: 1 ) – Please choose one

For which values of the integer _value will the following code becomes an infinite

loop?

int number=1;

while (true) {

cout << number;

if (number == 3) break;

number += integer_value; }

any number other than 1 or 2

► only 0

only 1

only 2

Question No: 6 ( Marks: 1 ) – Please choose one

.

Each pass through a loop is called a/an

enumeration

Iteration

culmination

pass through

Question No: 7 ( Marks: 1 ) – Please choose one

A continue statement causes execution to skip to

the return 0; statement

► the first statement after the loop

the statements following the continue statement

the next iteration of the loop

Question No: 8 ( Marks: 1 ) – Please choose one

What is the correct syntax to declare an array of size 10 of int data type?

int [10] name ;

name[10] int ;

► int name[10] ;

int name[] ;

.

Question No: 9 ( Marks: 1 ) – Please choose one

Consider the following code segment. What will the following code segment display?

int main(){

int age[10] = {0};

cout << age ;

}

Values of all elements of array

Value of first element of array

► Starting address of array

Address of last array element

Question No: 10 ( Marks: 1 ) – Please choose one

What will be the correct syntax to initialize all elements of two-dimensional array to

value 0?

► int arr[2][3] = {0,0} ;

int arr[2][3] = {{0},{0}} ;

int arr[2][3] = {0},{0} ;

.

int arr[2][3] = {0} ;

Question No: 11 ( Marks: 1 ) – Please choose one

How many bytes will the pointer intPtr of type int move in the following statement?

intPtr += 3 ;

► 3 bytes

6 bytes

12 bytes

24 bytes

Question No: 12 ( Marks: 1 ) – Please choose one

If there are 2(n+1) elements in an array then what would be the number of iterations

required to search a number using binary search algorithm?

► n elements

(n+1) elements

2(n+1) elements

2(n+1) elements

Question No: 13 ( Marks: 1 ) – Please choose one

.

Which of the following operator is used to access the value of variable pointed to by a

pointer?

* operator

-> operator

&& operator

► & operator

Question No: 14 ( Marks: 1 ) – Please choose one

The ________ statement interrupts the flow of control.

switch

continue

goto

► break

Question No: 15 ( Marks: 1 ) – Please choose one

Analysis is the ————– step in designing a program

Last

Middle

Post Design

► First

.

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

Paying attention to detail in designing a program is _________

Time consuming

Redundant

► Necessary

Somewhat Good

Question No: 17 ( Marks: 1 )

Which programming tool is helpful in tracing the logical errors?

Question No: 18 ( Marks: 1 )

Give the syntax of opening file ‘myFile.txt’ with ‘app’ mode using ofstream variable

out’.

Question No: 19 ( Marks: 2 )

What is the difference between switch statement and if statement.

Question No: 20 ( Marks: 3 )

.

Identify the errors in the following code segment and give the reason of errors.

main(){

int x = 10

const int *ptr = &x ;

*ptr = 5 ;

}

Question No: 21 ( Marks: 5 )

If int array[10]; is an integer array then write the statements which will store values at

Fifth and Ninth location of this array,

Question No: 22 ( Marks: 10 )

Write a function BatsmanAvg which calculate the average of a player (Batsman),

Call this function in main program (Function). Take the input of Total Runs made

and Total number of matches played from the user in main function

Education In Pakistan © 2016