CS 201 Solved - Paper
http://vubest.blogspot.com
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
The functions toupper and islower are part of the character handling library
Question No: 3 ( Marks: 1 ) - Please choose one
How many parameter(s) function getline() takes?
► 0
► 1
► 2
► 3
http://groups.google.com/group/vuZs
inFile.getLine(name, maxChar, stopChar); The first argument is a character array, the array should be large enough to hold the complete line. The second argument is the maximum number of characters to be read. The third one is the character if we want to stop somewhere.
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 Rational: number += integer_value above line decide the fate of loop so any thing other then zero leads to value of 3 which will quite the loop. Only zero is the value which keeps the loop infinite. http://groups.google.com/group/vuZs 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 continue statement is used, when at a certain stage, you don’t want to execute the remaining statements inside your loop and want to go to the start 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 one int is 4 bytes so 4*3 = 12 bytes movement. 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.
http://groups.google.com/group/vuZs
► 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
analysis will be always followed by design and then code.
Question No: 16 ( Marks: 1 ) - Please choose one
Paying attention to detail in designing a program is _________
► Time consuming
► Redundant
► Necessary
► Somewhat Good
In programming, the details matter. This is a very important skill. A good programmer always analyzes the problem statement very carefully and in detail. You should pay attention to all the aspects of the problem.
Question No: 17 ( Marks: 1 )
Which programming tool is helpful in tracing the logical errors?
Debugger is used to debug the program i.e. to correct the
Question No: 18 ( Marks: 1 )
Give the syntax of opening file ‘myFile.txt’ with ‘app’ mode using ofstream variable ‘out’.
out.open(“myfile.txt” , ios::app);
Question No: 19 ( Marks: 2 )
What is the difference between switch statement and if statement.
The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be executed.
Question No: 20 ( Marks: 3 ) http://groups.google.com/group/vuZs
Identify the errors in the following code segment and give the reason of errors.
main(){
int x = 10
const int *ptr = &x ;
*ptr = 5 ;
}
Answer
*ptr = 5;
declaring a pointer to a constant Integer. You cannot use this pointer to change the value being pointed to:
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,
arrary[4] = 200;
arrary[8] = 300;
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
#include // allows program to output data to the screen
// function main begins program execution
int BatsmanAvg(int TotalRuns, int TotalMatches) ;
main()
{
int stopit;
int TotalRuns, TotalMatchesPlayed =0;
cout << "Please Entere the total Runs made : " ; cin>> TotalRuns ;
cout << "Please Entere the total match played : " ; cin>> TotalMatchesPlayed ;
cout << "\n Avg Runs = " << BatsmanAvg(TotalRuns,TotalMatchesPlayed); cin>> stopit; //pause screen to show output
}
int BatsmanAvg(int TotalRuns, int TotalMatches)
{
return TotalRuns/TotalMatches;
}
Question No: 1 ( Marks: 1 ) - Please choose one
In C/C++ the #include is called,
►Header file
►Preprocessor Directive
►Statement
►Function
Question No: 2 ( Marks: 1 ) - Please choose one
When the logical operator AND (&&) combine 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
Question No: 3 ( Marks: 1 ) - Please choose one
Header file: fstream.h includes the definition of the stream classes.
http://groups.google.com/group/vuZs
►ifstream, fstream, cout
►ifstream, fstream, ofstream
►fstream, cin, cout
►None of the above
Question No: 4 ( Marks: 1 ) - Please choose one
How many parameter(s) function getline() takes?
► 0
► 1
► 2
► 3
istream& istream::getline( char* buffer, streamsize num, char delim );
Question No: 5 ( Marks: 1 ) - Please choose one
Disks is divided into ____________ with power of__________.
Chunks, 2
Chunks, 2n
Blocks, n2
Blocks, 2n
http://groups.google.com/group/vuZs
Question No: 6 ( Marks: 1 ) - Please choose one
Function seekg() takes ____________ parameter(s).
0
1
2
3
istream& seekg ( streamoff off, ios_base::seekdir dir );
http://vubest.blogspot.com
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
The functions toupper and islower are part of the character handling library
Question No: 3 ( Marks: 1 ) - Please choose one
How many parameter(s) function getline() takes?
► 0
► 1
► 2
► 3
http://groups.google.com/group/vuZs
inFile.getLine(name, maxChar, stopChar); The first argument is a character array, the array should be large enough to hold the complete line. The second argument is the maximum number of characters to be read. The third one is the character if we want to stop somewhere.
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 Rational: number += integer_value above line decide the fate of loop so any thing other then zero leads to value of 3 which will quite the loop. Only zero is the value which keeps the loop infinite. http://groups.google.com/group/vuZs 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 continue statement is used, when at a certain stage, you don’t want to execute the remaining statements inside your loop and want to go to the start 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 one int is 4 bytes so 4*3 = 12 bytes movement. 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.
http://groups.google.com/group/vuZs
► 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
analysis will be always followed by design and then code.
Question No: 16 ( Marks: 1 ) - Please choose one
Paying attention to detail in designing a program is _________
► Time consuming
► Redundant
► Necessary
► Somewhat Good
In programming, the details matter. This is a very important skill. A good programmer always analyzes the problem statement very carefully and in detail. You should pay attention to all the aspects of the problem.
Question No: 17 ( Marks: 1 )
Which programming tool is helpful in tracing the logical errors?
Debugger is used to debug the program i.e. to correct the
Question No: 18 ( Marks: 1 )
Give the syntax of opening file ‘myFile.txt’ with ‘app’ mode using ofstream variable ‘out’.
out.open(“myfile.txt” , ios::app);
Question No: 19 ( Marks: 2 )
What is the difference between switch statement and if statement.
The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be executed.
Question No: 20 ( Marks: 3 ) http://groups.google.com/group/vuZs
Identify the errors in the following code segment and give the reason of errors.
main(){
int x = 10
const int *ptr = &x ;
*ptr = 5 ;
}
Answer
*ptr = 5;
declaring a pointer to a constant Integer. You cannot use this pointer to change the value being pointed to:
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,
arrary[4] = 200;
arrary[8] = 300;
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
#include
// function main begins program execution
int BatsmanAvg(int TotalRuns, int TotalMatches) ;
main()
{
int stopit;
int TotalRuns, TotalMatchesPlayed =0;
cout << "Please Entere the total Runs made : " ; cin>> TotalRuns ;
cout << "Please Entere the total match played : " ; cin>> TotalMatchesPlayed ;
cout << "\n Avg Runs = " << BatsmanAvg(TotalRuns,TotalMatchesPlayed); cin>> stopit; //pause screen to show output
}
int BatsmanAvg(int TotalRuns, int TotalMatches)
{
return TotalRuns/TotalMatches;
}
Question No: 1 ( Marks: 1 ) - Please choose one
In C/C++ the #include is called,
►Header file
►Preprocessor Directive
►Statement
►Function
Question No: 2 ( Marks: 1 ) - Please choose one
When the logical operator AND (&&) combine 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
Question No: 3 ( Marks: 1 ) - Please choose one
Header file: fstream.h includes the definition of the stream classes.
http://groups.google.com/group/vuZs
►ifstream, fstream, cout
►ifstream, fstream, ofstream
►fstream, cin, cout
►None of the above
Question No: 4 ( Marks: 1 ) - Please choose one
How many parameter(s) function getline() takes?
► 0
► 1
► 2
► 3
istream& istream::getline( char* buffer, streamsize num, char delim );
Question No: 5 ( Marks: 1 ) - Please choose one
Disks is divided into ____________ with power of__________.
Chunks, 2
Chunks, 2n
Blocks, n2
Blocks, 2n
http://groups.google.com/group/vuZs
Question No: 6 ( Marks: 1 ) - Please choose one
Function seekg() takes ____________ parameter(s).
0
1
2
3
istream& seekg ( streamoff off, ios_base::seekdir dir );
Comments
Post a Comment