You are on page 1of 2

INSTITUTE OF PETROLEUM TECHNOLOGY, GANDHINAGAR

B.TECH - IN SEMESTER EXAM-1


COMPUTER PROGRAMMING (161)
Roll No. _____ Batch No. ____

DATE: 13-09-2007 TIME: 9.30 A.M. TO 10.30 A.M.


TOTAL MARKS: 20

Q.1. State whether the following statements are true or false. [5]

1. Long double variable occupies 10 bytes in the memory.


2. The range of unsigned char is -128 to 127.
3. For an arithmetic operation involving two floating-point operands, the
operand with lesser precision is converted to the type of the operand
with greater precision.
4. Every C++ program must have function prototype declaration for all the
functions to be used in the program.
5. Keyword return is used to return a value from the called function and to
return to calling function.
6. With short-cut key “Ctrl+F5” user can move to output window.
7. ASCII-8 represents 128 different combinations.
8. With C++, you can follow the top-down approach of programming.
9. = = is used to check equality condition.
10. The output of the following statement is 15.
cout << "6+18/2";

Q.2. Do the following conversion. [2]


1. (ABC.25)16 = ( ? )10
2. (10.75)10 = ( ? )2
3. (15.625)8 = ( ? ) 10
4. (101101.11001)2 = ( ? )10

Q.3. Find out the Errors in the following program and


rewrite the whole program. [3]
#include <iostraem.h> Int comparequal(int , int y);
#include <stdio.h> {
If ( x = y)
main (void) return x
{ else
clrscr(); return y;
Int x, y; }
cin << x << y;
z = comparequal(x y);
cout >> z;
getch();
}

Page 1 of 2
INSTITUTE OF PETROLEUM TECHNOLOGY, GANDHINAGAR
B.TECH - IN SEMESTER EXAM-1
COMPUTER PROGRAMMING (161)
Roll No. _____ Batch No. ____

Q.4. What will be the output of the following program. [2]

#include <iostream.h>
void main( )
{
int k, num = 30;
k = (num > 5 ? (num <= 10 ? 100: 200) : 500 );
cout << k;
}

Q.5. Write algorithm for the following. [3]

G.E.B. applies following rates as electricity charges.

units consumed charges per unit.


<= 50 1.25
For next 50 units 1.75
For next 100 units 2.00
For units above 200 2.25

The minimum amount of bill will be Rs. 75/-.


Calculate the bill amount based on the units consumed.

Q.6. Write whole C++ programs for the following USING FUNCTION(S)
only. (Any two out of three.) [5]

1. Accept kilobytes from the user and convert them into bytes, megabytes
and gigabytes.
2. To calculate the sum and average of any 5 values. (The input operation
should be performed in function called sumavg and the output should be
displayed in the main function.)
3. Nokia Co. has launched several mobiles in the market, generally
identified by the model number. Accept model number from the user
and display model name using following table.

Model Number Model Name


70 Nokia N70 Music Edition with Dual Camera
91 Nokia 91 GSM
9500 Nokia 9500 Communicator
If the model no. is not found, then print the message: "Not Available".

Page 2 of 2

You might also like