Institute of Petroleum Technology, Gandhinagar B.Tech - in Semester Exam-1 Computer Programming

Download as doc, pdf, or txt
Download as doc, pdf, or txt
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: 28-11-2007 TIME: 11.00 A.M. TO 12.00 A.M.


(FOR STUDENTS WHO HAVE NOT APPEARED IN IN-SEM-1)
TOTAL MARKS: 20

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

1. Continue is a keyword.
2. Const is used to declare those variable whose value can not be changed.
3. Keyword return is used to return a value from the called function and to
return to calling function.
4. Double variable occupies 10 bytes in the memory.
5. With short-cut key “Alt+F9” user can compile & run the program.
6. EBCDIC represents 64 different combinations.
7. The range of int is -32767 to 32768.
8. In C++, the size of character array should be one larger than the number
of characters in the string.
9. In Switch statement, default is compulsory.
10. In C++, the statement x = (y = 10); is a valid statement.

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


1. (1101.101)16 = ( ? )10
2. (1101.101)10 = ( ? )2
3. (1101.101)8 = ( ? ) 10
4. (1101.101)2 = ( ? )10

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


rewrite the whole program. [3]
#include <iostream.h> swap void (int a, int b);
#include <stdio.h> {
C = a;
Void main ( ) a = b;
{ b = c;
Cout a b;
float a, b, c; }
cin << A << B;
c = swap(A,B);
cout >> c
getc();
}

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 expression and show their
hierarchy. [2]

g = big / 2 + big * 4 / big – big + abc / 3;


(abc = 2.5, big = 2, assume g & abc to be a float while big to be an int)

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

A cashier has currency notes of denominations 1, 5, 20 & 50 only. Accept the


amount to be withdrawn from the keyboard. Find the total number of currency
notes of each denomination the cashier will have to give to the withdrawer.

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

1. A company insures its drivers in the following cases:


- If the driver is married.
- If the driver is unmarried, male and above 30 years of age.
- If the driver is unmarried, female and above 25 years of age.
In all other cases the driver is not insured. If the marital status, sex and
age of the driver are the inputs, write a program to determine whether
the driver is to be insured or not.

2. To print the table of any number.


Note: Accept the number in the main( ) , while table should be printed
from the function.

Page 2 of 2

You might also like