MIDTERM EXAM CS201- Introduction to Programming
Descriptive questions:-
Question No:
17 ( Marks: 1 )
To
Which category of the software “Compiler and Interpreter” belongs?
System
Software
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.”
0 comments: