0% found this document useful (0 votes)
61 views2 pages

CP Btech 08 Mid Sem 19 09 08

This document contains instructions and questions for a Computer Programming mid-semester exam. It includes multiple choice, fill-in-the-blank, and short answer questions about C/C++ programming concepts like arrays, loops, functions, algorithms, and header files. Students are asked to write and analyze code segments, draw flowcharts, and write complete programs to remove an element from an array based on user input.

Uploaded by

darshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views2 pages

CP Btech 08 Mid Sem 19 09 08

This document contains instructions and questions for a Computer Programming mid-semester exam. It includes multiple choice, fill-in-the-blank, and short answer questions about C/C++ programming concepts like arrays, loops, functions, algorithms, and header files. Students are asked to write and analyze code segments, draw flowcharts, and write complete programs to remove an element from an array based on user input.

Uploaded by

darshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

PANDIT DEENDAYAL PETROLEUM UNIVERSITY

INSTITUTE OF PETROLEUM TECHNOLOGY, GANDHINAGAR


B.TECH 2008-MID-SEMESTER EXAM COMPUTER PROGRAMMING (ESC101)
Roll No. _____ Batch No. ____

DATE: 19-09-2008 TIME: 9.30 A.M. TO 11.30 A.M. TOTAL MARKS: 50

Instructions:
1. Do Not Repeat Questions.
2. Answer New Question on New Page.
3. Q.1 to Q.8 are compulsory.
4. Q.9 is bonus question of 5 marks.

Q.1. State whether the following statements are true or false. [5]
A) Array occupies contiguous memory locations.
B) In c/c++, all arrays have 0 as the index of their first element.
C) Keywords can be used as variable names.
D) ASCII-7 uses leftmost 7 bits of a byte.
E) BCD is unable to store 26 lower case alphabets.
F) You can’t add an integer number to a pointer.
G) char name[] = “PDPU-IPTG” occupies 9 bytes in the memory.
H) strlen() returns length of a string.
I) strcmp() returns 0 if both strings are equal.
J) while(1); is an infinite loop statement.

Q.2. Fill in the Gaps. [5]


A) _____ is used to access a specific element in the array.
B) The format string for unsigned int is _____.
C) _____ escape sequence character puts the cursor at the 1st position in the line.
D) _____ is an exit-controlled loop structure.
E) _____ is used to override precedence rules.

Q.3. Do the following: (show working also.) [5]


A) (1110111)2 + (1010101)2 = ( ? )10
B) (AB.CD)16 = ( ?) 8
C) (705.25)8 = ( ? ) 2
D) Convert (-105)10 into 2's complement using 9 bits.
E) Convert (-20.0625)10 into IEEE 754 standard (32 bits)

Q. 4. Write the output for the following segment of the program. [5]
a) int i = 4 , j = 5; b) int a = 10, * b = &a, **c = &b;
if (++i > j - -) **c = *b + 10; c++;
cout << i << “ “ << j ; cout << *c;
cout << i << “ “ << j ; (if addresses of a ,b and c are 65524,
65522 & 65520 respectively.)
(Assume 16-bit compiler)

c) int p = 30 , c = 80, m = 90, a;


a = ( p + c + m ) / 3;
cout << (p < 35 || c < 35 || m < 35)?”Fail”:(a>=70)?”Distinction”: (a>=60)?”First Class”:
(a>=50)?”Second Class”:”Third Class”;

Page 1 of 2
PANDIT DEENDAYAL PETROLEUM UNIVERSITY
INSTITUTE OF PETROLEUM TECHNOLOGY, GANDHINAGAR
B.TECH 2008-MID-SEMESTER EXAM COMPUTER PROGRAMMING (ESC101)
Roll No. _____ Batch No. ____

d) int i, j, k; e) int a[5], i;


for(i = 1 ; i <= 5 ; i++) a[0] = 1;
{ for(i=1;i<=3;i++)
k = 0; {
for(j=1; j <= i; j++) a[i] = a[i-1] * 10;
{ cout << a[i] << endl;
cout << (( k = = 0)?1:0); }
k++;
}
cout << endl;
}

Q.5. Find out 10 errors in the following segment of the program & rewrite it. [5]
main( ) Dbl(int x, int y);
{ {
int a = 10; b = 20; int x;
dbl(&a, &b); x = x + x;
cout >> a >> “ “ >> b; y = y + y;
} }

Q.6. Write algorithm for the following. [10]


Find out the integer number whose factorial is given to us. e.g. if user enters 120  the
output should be 5. Give appropriate message, if you are unable to find the exact value.
Or
Q.6. Draw flowchart to calculate the value of a raised to b. (ab) [10]
Where b should be a positive integer only. Reenter the value of b, if it is not
positive.

Q.7. Write C/C++ program for the following. [10]


A) Summation of digits of a given no. e.g. 351 = 3+5+1 = 9
B) Find out largest and smallest out of 100 different nos.

Q.8. Write short note on the following. [5]


A) printf ( ) B) Header Files

Q.9. Bonus Question: [5]


Write a complete C/C++ program to remove a particular number from the array having 10
elements.
e.g. array contains { 1 , 3, 5, 3, 2, 4 ,6, 3, 2, 7 }. After removing 3 from the array, the array
should look like {1, 5, 2, 4, 6, 2, 7, 0, 0, 0}.
Ask the contents of the array and the number to be removed from the user.

Page 2 of 2

You might also like