0% found this document useful (0 votes)
34 views

TA GC 162 Computer Programming 1

This document contains instructions and questions for a computer programming exam. It includes 13 multiple choice and short answer questions testing knowledge of computer architecture, operating systems, C programming, and assembly language. Students are instructed to show all work and write answers on the provided answer sheet using pen. Calculators and phones are not allowed. The exam is divided into two parts, with Part A being 1 hour and Part B to follow upon completion of Part A.

Uploaded by

sachnish123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

TA GC 162 Computer Programming 1

This document contains instructions and questions for a computer programming exam. It includes 13 multiple choice and short answer questions testing knowledge of computer architecture, operating systems, C programming, and assembly language. Students are instructed to show all work and write answers on the provided answer sheet using pen. Calculators and phones are not allowed. The exam is divided into two parts, with Part A being 1 hour and Part B to follow upon completion of Part A.

Uploaded by

sachnish123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

.

~ INSTITUTE OF TECHNOLOGY & SCIENCE- PILANI, GOA CAMPUS


Second Semester 2004-2005
Time: 9:00 am to 12:00
.use No. : TA GC162 Max. Marks: 90
~ourse Title : Computer Programming - 1 Date : 04/05/05
Component: Comprehensive Exam (CB)
PART -A
MAXIMUM DURATION: 1 HOUR
PART-B WILL BE ISSUED ONLY ON RETURN OF PART-A TO THE INVIGILATOR

Note: Use the answer sheet provided to write your answers. Name, ID no, Lecture Section number
and Instructor's name has to be written clearly. All answers should be in pen. Answers in pencil
will not be evaluated. No overwriting is allowed
Use of calculators and Mobile phones is not allowed
Partial marks will not be assigned to any answer in Part A

1. The components of a computer in the Von Neumann model are (1)

2. Rearrange the storage systems given below in a proper hierarchy based on the speed of computing of
each system. Ensure that the hierarchy starts with the fastest system.
(Answer should be indicated using alphabets A to G).
A) Optical disk B) Electronic disk C) Registers D) Main memory
E) Magnetic disk F) Magnetic tapes G) Cache
(2)
3. State whether the following statements are True or False:
a) Accessing privileged instruction by user will cause TRAP to operating system.
b) Multiprogramming is an instance where the operating system makes decisions for the
user.
c) A bootstrap program is used to handle interrupts and traps.
d) Synchronous I/O is preferred because it increases system efficiency.
(0.5x4=2)
4. Given below are the various actions that occur when an interrupt occurs. Rearrange the same in the
correct order in which they occur: Answer using alphabets A to E.
A. Control transferred to interrupt-service routine to handle interrupt
B. CPU registers and program counter are loaded again
C. CPU resumes interrupted computation
D. Control transferred from interrupt-service routine
E. Contents of CPU registers & PC are saved
(2)
S. In the Linux OS give commands for:
a. List all the files in a directory named dirS
b. List all the processes of a user with usemame a04
c. Deleting all files with the yes/no option
d. Renaming a fiJe oldfile to newfile
(0.5x4=2)

6. Give in correct order all the phases that occur in an LC3 ADD instruction. (2)

7. a. The contains the address of the next instruction. (1)


b. The addressability of LC3 is (1)

8. Nameall possiblestatesthat a processcan be in. (2)


9. What will be the output of following fragment of program code?

mainO {
int i=45; float c; c=check{i); printf{"c=%f ,c);
}
check (int ch) {
if{ ch>=45)
return (3.14);
else
return (6.28);
} (3)

10. What will be the output of following fragment of program code?

mainO {
int j, x=O;
for (j=0; j<=5; j++) {
switch 0-1) {
case 0: case -1: x+=1; break; case 1: case 2: case 3: x+=2; break;
default: x+=3;
}
printf{"%d \t" ,x);
}
} (3)
11.What will be the output of following fragment of program code?

mainO{
int x=3, y, z; z = y = x; z = y + = x = - z;
printf{"%d . %d , %d" , x , y, z );
} (3)

12. What will be the output of following fragment of program code?

main{){
int a=3, b=4; b % = 3 + 4; a * = a + 5; printf{"%d,%d", b, a);
} (3)

13. What will be the output of following program code ?


(ASCII Code of character A is 65 and a is 97)
mainO {
int arr1[ 3 ], arr2[ 3 ]; int i;
for (i=O; i < 3; i ++) {
arr1[ i ] = 'A' + i;
arr2[ i ] = 'a' + i;
printf (" %d \t", arr2[ i] - arr1[ i]);
}
} (3)
A INSTITUTEOF TECHNOLOGY& SCIENCE-PILANI,GOACAMPUS
Second Semester 2004-2005
: TA GC162 Course Title : Computer Programming -1
.:nt : Comprehensive Examination (CO)

Jte: Lecture Section number, Instructor's name has to be written clearly. Write all details on both the
main answer sheet and the supplementary sheets. Every question has to be answered starting from a new
page. Attempt all the subsections of a question sequentially. All answer should be in pen. Answers
in pencil will not be evaluated. Calculations and justification for each answer should be given.
PART-O

1. Obtain the largest number in the list given below. The subscript indicates the base of the number
system for each number.(Justifyyour answerwith propercalculations.)
a) (126)10 b) (1l1l111)2 c) (175)8 d) (81)16 (4.5)

2. An equation written by an ancient civilization has been decoded and is given below:
13+15=31 .
Assume that they followed a positional notation (much like the decimal system that we follow for
example, (25)10 = 2* 1QI"I + 5* 10/\0). Give proper calculations to determine the base of the
number system that they followed. (3.5)
3. C lete the tabl --- bel
- ---
Decimal 16-Bit 2's Complement 16-BitHex (4 Hex Digits)
-748
0000111100001111 (4)

4. Write a program in C to calculate the sum of every third integer starting from 2 upto 100, (a) using
a while statement (b) using a do-while statement (c) using a for statement. (6)


5. Write a C program with a function to calculate the sum of rows of an nxm matrix. Note that
The main program should take the values of nand m from the keyboard.


It should initialize the matrix with values from the keyboard.
It should call the function to calculate the sum of elements of each row.


It should print the original matrix and the result (sum of each row) in a column on the monitor.
The program should be complete with all declarations and initializations. (9)

6. Give the truth table for the logical expression NOT (NOT (A) OR NOT (B.
What single logic gate has the same truth table? (2)

7. Give the truth table for a 4-to-l mux. Implementa 4-to-l mux using only 2-to-l mux blocks. (4)

8. Given below is the circuit for a 4-bit full-adder. Make necessary connections to make it work as a
4-bit full-adderlsubtractor for 2's complement numbers. Describe its working. (4)

n n
--

)C-oR.
o!e --:r..L
I
11 i
{{OF

rA3 I.-, I FA%.If.. j FAI


IE, I FAo c. t (C 0)
J I.
C S tt " t. - Co So
9. Draw a flowchart to represent the following LC-3 program:
.ORIG x3000
AND RO, RO, #0
---
-Ib
ADD RO, RO, # -\0/
-1,(,
ADD RO, RO, #-"t
AND R1, R1, #0
ADD R1, R1, #-3
AND R3, R3, #0
ADD R3, R1, #0
BRp START
NOTR1,R1
ADD R1, R1, #1
NOT RO, RO
ADD RO, RO,#1
START AND R4, R4, #0
MULTI ADD R4, R4, RO
ADD R1, R1,#-1
BRp MULTI
ADD R3, R3, #0
BRp DONE
NOT R4, R4
ADD R4, R4, #1
DONE STI R4, LOCATION
HALT
.END
LOCATION .FILL x4000 (10)

10. For a certain electrical circuit with inductance L and resistance R, the damped natural
frequency is given by

JH
Frequency= ---
LC 4C2
R2

It is desiredto study the variation of this frequencywith C (capacitance).Draw a flow chart to


calculatethe frequency for different values of C, startingfrom 0.001 to 0.1 in steps of .001. (13)

You might also like