Friday 25 July 2014

Past Papers dowload

http://virtualuniversity007.blogspot.com/
cs Mid term papers
(MN. Date 26 , 10am)
Explain the logic of each statement of the given code segment.
Streampos orig = aFile.tellp();
aFile.seekp(0, ios::end); (05)
Write a program which prompts the user to enter 10 elements of type int and stores them
into an array. Program should display only those elements whose indices are divisible by
2.
Hint: Use pointer to display the array elements whose indices are divisible by 2. (05)
Write the code for a structure called Inventory having the following elements:
A character array named partName
An integer named partNumber
An integer named stock.
(03)
Which one of the following is the better approach in terms of memory space occupation
and why ?
1. char *arr[] = {“programming”, “fundamental”, “cs201”};
char arr[3][50] = {“programming”, “fundamental”, “cs201”}; (03)
Write a statement for opening file trans.txt for input; using an ifstream object called
inTransaction. (02)
Write the code to access the element at third row and second column of a 2D array uses pointer
named arrayptr . (02)
MCQS
Syntax of a union is identical to __________ .
structure
Class
Function
Oop
A union is a user-defined data type that contains only _______from its list of members at a
time.
http://virtualuniversity007.blogspot.com/
one object
two objects
three objects
four objects
Which of the given file handling modes are similar in their functionality ?
ios::out, ios::trunk
ios::trunc, ios::ate
ios::trunc, ios::nocreate
ios::trunc, ios::ate
Which one of the given option is not a mode for reading/writing the data from a file?
In
Out
Trunk
Get
In C/C++, the header file used for string manipulation is __________.
stdlib.h
string.h
strings.h
stype.h
A 2D array multi[5][10] can be accessed using the array name as **multi , this technique is
called __________.
Single referencing
Single dereferencing
Double referencing
Double dereferencing
C language was evolved from _____ language(s).
BASIC
C++
B and BCPL
FORTRAN
The __________ statement forces the immediate next iteration of the loop.
Switch
Goto
Continue
Break
_________ are very good tools for code reuse.
Operators
Loops
Functions
Variables
When an argument is passed by reference, ___________
the function cannot access the argument’s value.
a variable is created in the function to hold the argument’s value.
a temporary variable is created in the calling program to hold the argument’s value.
the function accesses the argument’s original value in the calling program.
___________ executes all the lines before error and stops at the line which contains the error.
Intrepreter
Compiler
Linker
Debugger
Analysis is the -------------- step in designing a program.
Middle
Post design
First
Last
Which of the following is the correct function call, having array named student of 10
elements as a parameter?
addRecord(student[]);
addRecord(student);
addRecord(student[10]);
addRecord(*student);
When an array element is passed to a function, it is passed by ________________.
Reference
data type
value
data
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[] ; 
If we want to copy an array, both arrays need to be of same___________.
Elements and size
Data and size
Data type and size
Data and data type
Which of the following is the correct syntax to print multiple values or variables in a single
command using cout?
cout << "H" << x << "\n";
cout << "Hello" + x + "\n";
cout << "H", x, "\n";
cout << ("H" & x & "\n");
Which one of the statements given below is equivalent to x %= 5?
x = % x 5
x = x % 5
x = % 5
x % x = 5
The condition in loop should be a(n) ___________.
Arithmatic Expression
Constant Expression
Boolean Expression
Primary Expression
Which structure is represented by following flow chart ?
If condition
is true
Then Process
if-else structure
else-if structure
switch structure
if structure
2ND PAPER
Write the code for defining a structure Triangle with variables base, altitude and
hypotenuse are the structure members. (05)
Write a code which reads a string not greater than 20 characters from keyboard, stores it
in an array and displays it on the screen. (05)
Given below is the code segment of a file handling program. What is purpose of the
condition given in the while loop ?
while (!inFile.eof())
{
inFile >> name >> sal >> dept;
cout << name << "\t" << sal << " \t" << dept << endl;
}
(03)
Identify the error in the given code segment and explain the reason for error.
main()

{
int num1[5] = {5,8,3,6,9};
int *ptr;
ptr = num1;
num1++;
return 0;
}
(03)
Which standard library must be included in a program to perform file read and write
operations? (02)
Write down the output of the following code segment?
int x[10] = {0,1, 2, 3, 4, 5, 6, 7, 8, 9};
int *xptr;
xptr = &x[5];
cout << *(xptr++) + 1; (02)
MCQS
Stream which sends data to the program is called _________.
Input stream
Output stream
Inline stream
Function stream
Syntax of a union is identical to __________ .
Structure
Class
Function
Loop
When accessing a structure member, the identifier to the left of the dot operator is the
name of ______________.
a structure member
a structure tag
a structure variable
the keyword struct
The parameter passed to isdigit() function is ____________.
a character variable
 
a boolean variable
an integer variable
a character string
TWAIN stands for _________ .
Technology With An Interesting Name
Technology Without An Informative Name
Technology Without An Interesting Name
Technology With An Informative Name
______ translates high level language program into machine language code.
Compiler
Linker
Debugger
Editor
From the option given below, what will be the correct output of the code?
for (int a = 1; a <= 3; a++)
cout<<a*3-1<<" ";
2 4 6
2 5 8
no output is displayed
1 2 3
If the return type of a function is void then it means that it will _________.
return any type of data
return some specific type of data
return no data
return just character data
The functions that have already been defined as a part of the language are called
___________.
user-defined functions
programmer-defined functions
inner funtions
built-in functions
Given that doubleArray is an array of 7 integers. Which of the below is the correct
statement to access the 5th element of the array?
doubleArray[7]

doubleArray[4]
doubleArray{7}
doubleArray(4)
The symbol which is used to represent a process in a flow chart is __________.
Rectangle
Arrow
Oval
Circle
When an array is passed to a function, by default it will be passed by_____________.
Data
Reference
Value
Data type
What is the range of Random number generator function rand()?
0 – 32768
1 – 32768
0 – 32767
1 – 32767
The first character of a variable name must be an alphabet or ________________.
Underscore
Digit
Special character
Comma
In ________, the first pointer stores the address of the some other pointer, which contains the
address of any variable.
single dereference
double dereference
single reference
double reference
Initialization of variable at the time of definition is --------------practice.
Bad Programming
Necessary
Good Programming
Not a necessary
  
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
You can use a _________ statement to transfer control elsewhere out of the nested structure.
Continue
Goto
Pause
Break
Which of the following array is the most suitable for storing a matrix structure?
Single-dimensional array
Two-dimensional array
Three-dimensional array
Four-dimensional array
Write a C/C++ program which defines an array of 15 elements. This program changes all
uppercase letters of an array into lowercase letters and all lowercase letters to uppercase
using character handling functions. (05)
Write down the output of following code segment.
int num[10] = {2, 3, 5, 8, 9, 10, 12, 15, 19, 20} ;
int *ptr = num ;
for (int i=0; i<10; i+=2){
cout << *(ptr+i) << “, ”;
} (05)
What will be the output of given program code?
main()
{
char province[] = "Sindh";
char s[80];
strcpy(s, "Hyderabad");
strcat(s, " and ");
 
strcat(s, province);
cout << s;
(03)
}
What will be the output of following code segment?
void func(int [], int);
main(){
int arr[3] = {2, 3, 5} ;
func(arr, 3) ;
for (int i = 0; i<3; i++)
cout << arr[i] << "";
}
void func(int a[], int size){
for (int i = 0; i<size; i++)
a[i] = 2*a[i];
}
(03)
What happens if we open an existing file using the default output mode and write the data
into the file ? (02)
A two-dimensional array has 3 rows and 4 columns. Write down the syntax to initialize
first element of all three rows of two-dimensional array with value 2. (02)
The microsoft word document(.doc) is a kind of __________ .
Sequential File
Random Access File
Binary Access File
Executable File
A union is a user-defined data type that contains only _______from its list of members at
a time.
one object
two objects
three objects
four objects
In C/C++, ___________ are the doors through which data can enter and come out of a
program.


Streams
Fields
Variables
Header files
Which one of the given option is not a mode for reading/writing the data from a file?
In
Out
Trunk
Get
C++ views each file as a sequential stream of ___________.
Bits
Bytes
Numbers
Words
In 2D array, the technique used to access the array elements is called ___________
Single referencing
Double referencing
Double dereferencing
Single dereferencing
From the options given below, identify the correct option which is used for calling the
function float square (int &);
square (int num);
square (&num);
square (num);
square (*num);
Identify the correct option which is used for calling the function float area (int).
area(&num) ;
area(num) ;
area(int num) ;
area(*num) ;
Which kind of error occurs in the code below to access the variable num in the main
function?
int num =10;

int main(){
int x ;
x = num ;
}
Syntax error
Logical error
Run time error
No error
A program statement that invokes a function is called _________.
function declaration
function call
function definition
function prototype
What will be the output of the following code segment?
main(){
int a = 10 ;
int b =0;
int *x = &a;
b = (*x)+3 ;
cout << a << “, ” << b ;
}
10,0
10,3
10,13
0,13
When the logical operator AND (&&) combines two expressions exp1 and exp2 then the
result will be true only ____________
When both exp1 and exp2 are true
When both exp1 and exp2 are false
When exp1 is true and exp2 is false
When exp1 is false and exp2 is true

For which array, the size of the array should be one more than the number of elements in
an array?
int
double
float
char
What is the range of Random number generator function rand()?
0 – 32768
1 – 32768
0 – 32767
1 – 32767
To assigned a value to a character type variable, ________ are used around the value.
parenthesis ( )
single qoutes ' '
double qoutes " "
curly braces { }
In C/C++, the #include is called______________.
Header file
Preprocessor Directive
Statement
Function
The number 544.53 must be stored in _____ data type.
Int
Short
Float
Char
Use of the _________ statement violates the rules of structured programming.
Break
Continue
Goto
Switch
In Flow Chart, flow of control is represented by ____________.
Rectangle
Circle


Diamond
Arrow
What will be the correct syntax for initialization of pointer ptr of type int with variable x?
int ptr = &x ;
int ptr = x ;
int *ptr = &x ;
int ptr* = &x ;
Write a program which prompts the user to enter 10 elements of type int and stores them
into an array. Program should display only those elements whose indices are divisible by
2.
Hint: Use pointer to display the array elements whose indices are divisible by 2. (05)
Write the code for a structure called Inventory having the following elements:
A character array named partName
An integer named partNumber
An integer named stock.
(03)
Which one of the following is the better approach in terms of memory space occupation
and why ?
2. char *arr[] = {“programming”, “fundamental”, “cs201”};
char arr[3][50] = {“programming”, “fundamental”, “cs201”}; (03)
Write a statement for opening file trans.txt for input; using an ifstream object called
inTransaction. (02)
Write the code to access the element at third row and second column of a 2D array uses pointer
named arrayptr . (02)
MCQS
Syntax of a union is identical to __________ .
structure


Class
Function
Oop
A union is a user-defined data type that contains only _______from its list of members at a
time.
one object
two objects
three objects
four objects
Which of the given file handling modes are similar in their functionality ?
ios::out, ios::trunk
ios::trunc, ios::ate
ios::trunc, ios::nocreate
ios::trunc, ios::ate
Which one of the given option is not a mode for reading/writing the data from a file?
In
Out
Trunk
Get
2nd paper
Write the code for defining a structure Triangle with variables base, altitude and
hypotenuse are the structure members. (05)
Write a code which reads a string not greater than 20 characters from keyboard, stores it
in an array and displays it on the screen. (05)
Given below is the code segment of a file handling program. What is purpose of the
condition given in the while loop ?
while (!inFile.eof())
{
inFile >> name >> sal >> dept;
cout << name << "\t" << sal << " \t" << dept << endl;
}
(03)

Which standard library must be included in a program to perform file read and write
operations? (02)
Write down the output of the following code segment?
int x[10] = {0,1, 2, 3, 4, 5, 6, 7, 8, 9};
int *xptr;
xptr = &x[5];
cout << *(xptr++) + 1; (02)
MCQS
Stream which sends data to the program is called _________.
Input stream
Output stream
Inline stream
Function stream
Syntax of a union is identical to __________ .
Structure
Class
Function
Loop
When accessing a structure member, the identifier to the left of the dot operator is the
name of ______________.
a structure member
a structure tag
a structure variable
the keyword struct
The parameter passed to isdigit() function is ____________.
a character variable
a boolean variable
an integer variable
a character string
TWAIN stands for _________ .
Technology With An Interesting Name
Technology Without An Informative Name
Technology Without An Interesting Name
Technology With An Informative Name


______ translates high level language program into machine language code.
Compiler
Linker
Debugger
Editor
From the option given below, what will be the correct output of the code?
for (int a = 1; a <= 3; a++)
cout<<a*3-1<<" ";
2 4 6
2 5 8
no output is displayed
1 2 3
If the return type of a function is void then it means that it will _________.
return any type of data
return some specific type of data
return no data
return just character data
The functions that have already been defined as a part of the language are called
___________.
user-defined functions
programmer-defined functions
inner funtions
built-in functions
Given that doubleArray is an array of 7 integers. Which of the below is the correct
statement to access the 5th element of the array?
doubleArray[7]
doubleArray[4]
doubleArray{7}
doubleArray(4)
The symbol which is used to represent a process in a flow chart is __________.
Rectangle
Arrow
Oval
Circle
When an array is passed to a function, by default it will be passed by_____________.

Data
Reference
Value
Data type
What is the range of Random number generator function rand()?
0 – 32768
1 – 32768
0 – 32767
1 – 32767
The first character of a variable name must be an alphabet or ________________.
Underscore
Digit
Special character
Comma
In ________, the first pointer stores the address of the some other pointer, which contains the
address of any variable.
single dereference
double dereference
single reference
double reference
Initialization of variable at the time of definition is --------------practice.
Bad Programming
Necessary
Good Programming
Not a necessary
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
You can use a _________ statement to transfer control elsewhere out of the nested structure.
Continue
Goto
Pause
Break

Which of the following array is the most suitable for storing a matrix structure?
Single-dimensional array
Two-dimensional array
Three-dimensional array
Four-dimensional array
QUESTION:
Write down the output of the code given below?
#include <iostream>
using namespace std;
union Num
{
int ValueI;
float ValueF;
double ValueD;
char ValueC;
};
void main()
{
// Optional union keyword
// ValueI = 100
Num TestVal = {100};
cout<<"\nInteger = "<<TestVal.ValueI<<endl;
TestVal.ValueF = 2.123;
cout<<"Float = "<<TestVal.ValueF<<endl;
cout<<"Uninitialzed double = "<<TestVal.ValueD<<endl;
cout<<"Some rubbish???"<<endl;
TestVal.ValueC = 'U';
cout<<"Character = "<<TestVal.ValueC<<endl;
}
(05)
Write a program which declares and initializes an array of 10 integers and then displays
the 4th and 8th element of the array by using a pointer.

(05)
Perform left shift operation on a binary number 0101 and write the result in binary and
decimal.
(03)
Write the code for the declaration of a function named getMax which takes a 2D array of
integers(3x3 dimension) as its parameter and returns a double pointer to an integer.
(03)
Identify any logical or syntax error in the statement below and explain the reason of the error.
seekg (-10L, ios::beg);
(03)
Write the code to access the element at third row and second column of a 2D array uses pointer
named arrayptr . (02)
MCQS:
An object of _________ class can be created for saving the current position of any opened file
before reading from the file
Filepos
Streampos
Stream
Filestream
The value returned by the eof() function is of __________ type.
Integer
Float
Character
Boolean
If a file is not properly closed in a program then what is the status of the program ?
Runtime error will be generated in the program
The program will terminate normally
Compiler will generate syntax error
The Program will crash
The parameter passed to isdigit() function is ____________.
a character variable
a boolean variable
an integer variable
a character string

In C/C++, the header file used for string manipulation is __________.
stdlib.h
string.h
strings.h
stype.h
Arrays are best data structures _________.
they take least space in memory
for the size of the structure and the data in the structure are constantly changing
for relatively permanent collections of data
they take much space in memory
Each array declaration must provide the information about all these things except
__________.
Name of the array
Type of data stored in the array
The location of the first element to be stored
Number of elements of the array
The First step for developing a program is ____________.
Linking
Debugging
Analysis
Loading
___________ transfers the executable code from hard disk to main memory.
Linker
Loader
Editor
Interpreter
___________ operator is used to pass the address of a variable to the called function.
*
**
&&
&
In call by reference, __________ of a variable is passed to the called function.
Address
Size
Type
Value

___________ of a function is also known as signature of a function.
Definition
Declaration
Calling
Invoking
Preprocessor program performs its function before ______ phase takes place.
Editing
Linking
Compiling
Loading
Which of the following is the correct function call, having array named student of 10
elements as a parameter?
addRecord(student[]);
addRecord(student);
addRecord(student[10]);
addRecord(*student);
The remainder (%) operator is a __________operator.
Logical
Arithmetic
Relational
Conditional
Which of the following array is the most suitable for storing a matrix structure?
Single-dimensional array
Two-dimensional array
Three-dimensional array
Four-dimensional array

http://virtualuniversity007.blogspot.com/

2 comments:

  1. Free No Deposit Bonus Casino Codes - CasinoWow
    Free No Deposit Casinos Bonus Codes · 1. El Royale 바카라 Casino · 2. 인카지노 Red Dog Casino · 3. Caesars Casino · 4. 888casino · 5. Mr Green Casino 제왕카지노 · 6. Bovada

    ReplyDelete