CS201- SOLVED SUBJECTIVE MIDTERM PAPERS
Here is the Complete Collection of CS201 Solved subjective Midterm Paper of 2009. You Can Also Download CS201 Solved Mid Term Papers, CS201 Short Notes, CS201 Lecture Wise Questions Answers Files, CS201 Solved MCQs, CS201 Solved Quizzes , CS201 Solved Mid Term Subjective Papers , CS201 Solved Mid Term Objective Papers From the Links given at the end of this Post.
CS201 MIDTERM PAPER0 - 2009
Here is the CS201 Mid term Paper of 2009 Examination:
Also Read: Cs201 All Past Papers at one place
CS201 Midterm Question No. 1:
( Marks: 1 )
To Which category of the software “Compiler and Interpreter” belongs?
Answer: (page 11)
The compilers and interpreters also belong to the System Software category.
To Which category of the software “Compiler and Interpreter” belongs?
Answer: (page 11)
The compilers and interpreters also belong to the System Software category.
CS201 Midterm Question No. 2:
( Marks: 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
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
( 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.
Answer:
float tmp [10] = {1.0,2.0,3.0,4.0};
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.
Answer:
float tmp [10] = {1.0,2.0,3.0,4.0};
CS201 Midterm Question No. 4:
( Marks: 3 )
Write down the output of the following code?
int array[7], sum = 0;
for(int i=0;i
{
array[i] = i;
sum+= array[i];
}
cout<< “ Sum = “ <
Answer:21
Loop will run times starts from zero and add values from 1 to 6 which is equal to 21
Write down the output of the following code?
int array[7], sum = 0;
for(int i=0;i
{
array[i] = i;
sum+= array[i];
}
cout<< “ 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
{
A[i] = 2*A[i];
cout << A[i] << " ";
}
Answer:
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
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.”
int A[5] = {1 , 2, 3, 4};
int i;
for (i=0; i
{
A[i] = 2*A[i];
cout << A[i] << " ";
}
Answer:
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
CS201 Midterm Question No. 6:
( 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.”
Also Read: CS201 INTRODUCTION TO PROGRAMMING PREVIOUS MIDTERM PAPER 2013
CS201 Midterm Question No. 7:
( Marks: 1 )
Which programming tool is helpful in tracing the logical errors?
Answer: (page 13)
Debugger is used to debug the program i.e. to correct the logical errors.
Which programming tool is helpful in tracing the logical errors?
Answer: (page 13)
Debugger is used to debug the program i.e. to correct the logical errors.
CS201 Midterm Question No. 8:
( Marks: 1 )
Give the syntax of opening file ‘myFile.txt’ with ‘app’ mode using ofstream variable ‘out’.
Answer: (page 203)
out.open(“myfile.txt” , ios::app);
Give the syntax of opening file ‘myFile.txt’ with ‘app’ mode using ofstream variable ‘out’.
Answer: (page 203)
out.open(“myfile.txt” , ios::app);
( Marks: 2 )
What is the difference between switch statement and if statement.
Answer:
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.
What is the difference between switch statement and if statement.
Answer:
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.
CS201 Midterm Question No. 10:
( 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 ;
}
Answer:
*ptr = 5;
declaring a pointer to a constant Integer. You cannot use this pointer to change the value being
pointed to:
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:
CS201 Midterm Question No. 11:
( 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,
Answer:
arrary[4] = 200;
arrary[8] = 300;
If int array[10]; is an integer array then write the statements which will store values at Fifth and
Ninth location of this array,
Answer:
arrary[4] = 200;
arrary[8] = 300;
CS201 Midterm Question No. 12:
( 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;
}
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;
}
( Marks: 1 )__________
What is the output of the following program?
#include iostream.h
main ( ) {
int RollNo;
int rollno;
RollNo = 5;
rollno = 8;
cout << “Roll No is ” << rollno; }
Answer:
Program should not compile due to missing <> from following statement
#include iostream.h
if we ignore this then output should be
Roll No is 8
What is the output of the following program?
#include iostream.h
main ( ) {
int RollNo;
int rollno;
RollNo = 5;
rollno = 8;
cout << “Roll No is ” << rollno; }
Answer:
Program should not compile due to missing <> from following statement
#include iostream.h
if we ignore this then output should be
Roll No is 8
CS201 Midterm Question No. 14:
( Marks: 1 )_____________________
Why we include iostream.h in our programs?
Answer: page 15
iostream.h tells the C compiler to include the contents of a file, This is the name of the library
definition file for all Input Output Streams.
Why we include iostream.h in our programs?
Answer: page 15
iostream.h tells the C compiler to include the contents of a file, This is the name of the library
definition file for all Input Output Streams.
( Marks: 2 )
Find out error in the code given below:
if ( num % 2 = 0 )
cout << "The number is even" << endl;
Answer:
if ( num % 2 = 0 ) There should be extra = sign following is right statement
if ( num % 2 = =0 )
Find out error in the code given below:
if ( num % 2 = 0 )
cout << "The number is even" << endl;
Answer:
if ( num % 2 = 0 ) There should be extra = sign following is right statement
if ( num % 2 = =0 )
CS201 Midterm Question No. 16:
( Marks: 3 )
How learning to design programs is like learning to play soccer?
Answer: (page 6)
“Learning to design programs is like learning to play soccer. A player must learn to trap a ball, to dribble
with a ball, to pass, and to shoot a ball. Once the player knows those basic skills, the next goals are to learn
to play a position, to play certain strategies, to choose among feasible strategies, and, on occasion, to create
variations of a strategy because none fits. “
How learning to design programs is like learning to play soccer?
Answer: (page 6)
“Learning to design programs is like learning to play soccer. A player must learn to trap a ball, to dribble
with a ball, to pass, and to shoot a ball. Once the player knows those basic skills, the next goals are to learn
to play a position, to play certain strategies, to choose among feasible strategies, and, on occasion, to create
variations of a strategy because none fits. “
( Marks: 5 )
Write the procedure of data insertion in middle of the files by Merge Method practiced in older systems?
Answer: (page 218)
· Opened the data file and a new empty file.
· Started reading the data file from beginning of it.
· Kept on copying the read data into the new file until the location we want to insert data into is reached.
· Inserted (appended) new data in the new file.
· Skipped or jumped the data in the data file that is to be overwritten or replaced.
· Copied (appended) the remaining part of the file at the end of the new file
Write the procedure of data insertion in middle of the files by Merge Method practiced in older systems?
Answer: (page 218)
· Opened the data file and a new empty file.
· Started reading the data file from beginning of it.
· Kept on copying the read data into the new file until the location we want to insert data into is reached.
· Inserted (appended) new data in the new file.
· Skipped or jumped the data in the data file that is to be overwritten or replaced.
· Copied (appended) the remaining part of the file at the end of the new file
CS201 Midterm Question No. 18:
( Marks: 10 )
Write a recursive function that takes three arguments (an integer array, starting subscript ‘s’ and
ending subscript ‘e’ ).
In first recursive call, the function should display the array from subscript ‘s’ (s = 0) to ‘e’ (e =
size of array). In each successive call, the function should print the array from index s+1 to e. T
function should stop processing and return when starting subscript becomes equal to ending
subscript.
For example, if user enters values for array 2, 3, 4, 5, 6 then the recursive function must display the
following output.
2 3 4 5 6
3 4 5 6
4 5 6
5 6
6
Answer:
#include ;
void PrintArray(int arrayInput[], int &s, int &e);
main ( )
{
int pause;
int TestArray [6] = {1,2,3,4,5,6};
int StartPoint = 0;
int EndPoint = 5;
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cin >> pause;
}
void PrintArray(int arrayInput[], int& s, int& e)
{
for (int i = s; i<= e; i++)
{
cout<< arrayInput[i];
}
s=s+1;
}
Write a recursive function that takes three arguments (an integer array, starting subscript ‘s’ and
ending subscript ‘e’ ).
In first recursive call, the function should display the array from subscript ‘s’ (s = 0) to ‘e’ (e =
size of array). In each successive call, the function should print the array from index s+1 to e. T
function should stop processing and return when starting subscript becomes equal to ending
subscript.
For example, if user enters values for array 2, 3, 4, 5, 6 then the recursive function must display the
following output.
2 3 4 5 6
3 4 5 6
4 5 6
5 6
6
Answer:
#include ;
void PrintArray(int arrayInput[], int &s, int &e);
main ( )
{
int pause;
int TestArray [6] = {1,2,3,4,5,6};
int StartPoint = 0;
int EndPoint = 5;
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cout<<"\n";
PrintArray(TestArray , StartPoint, EndPoint);
cin >> pause;
}
void PrintArray(int arrayInput[], int& s, int& e)
{
for (int i = s; i<= e; i++)
{
cout<< arrayInput[i];
}
s=s+1;
}
CS201 Midterm Question No. 19:
( Marks: 1 )
Suppose ‘z’ is a variable of type int. What will be the result of x = 27/4:
Suppose ‘z’ is a variable of type int. What will be the result of x = 27/4:
CS201 Midterm Question No. 20:
( Marks: 1 )
Give the general syntax of definition of structure.
Answer: repeat
Question No: 19 ( Marks: 2 )
Consider the structure
struct Customer
{
int custnum;
int salary;
float commission;
};
A programmer wants to assign 2000 for the structure member salary in the above example of
structure Customer with structure variable cust1 What line of code should he write
Give the general syntax of definition of structure.
Answer: repeat
Question No: 19 ( Marks: 2 )
Consider the structure
struct Customer
{
int custnum;
int salary;
float commission;
};
A programmer wants to assign 2000 for the structure member salary in the above example of
structure Customer with structure variable cust1 What line of code should he write
CS201 Midterm Question No. 21:
( Marks: 3 )
What is compiler?
Answer: repeat
What is compiler?
Answer: repeat
CS201 Midterm Question No. 22:
( Marks: 5 )
What is the difference between while and for loop?
Answer:
when number of iterations known we use for loop otherwise we will use while loop
What is the difference between while and for loop?
Answer:
when number of iterations known we use for loop otherwise we will use while loop
CS201 Midterm Question No. 23:
( Marks: 10 )
Write a void function( ); that takes integer numbers from the user and then displays the sum of
odd and even numbers entered by the user. Your program should terminate if user enters a
negative number
Write a void function( ); that takes integer numbers from the user and then displays the sum of
odd and even numbers entered by the user. Your program should terminate if user enters a
negative number
Thanks for Reading. Subscribe Below To recieve CS201 Papers in Your Mail box. or You can Like our facebook Page.
Post a Comment