Вы находитесь на странице: 1из 10

University of Bahrain College of Information Technology Department of Computer Science Summer Semester, 2001-2002 ITCS101/CSC100 (Introduction to Computer Science

& IT) Final Exam Date: 21/8/2002 Time : 11:30 - 13:30

STUDENT NAME STUDENT ID # SECTION/ INSTRUCTOR ITCS101 CSC100

NOTE: THERE ARE 10 (TEN) PAGES IN THIS TEST QUESTION # 1 10 MARKS COMMENTS

15

15

10

15

15

20

TOTAL

100

Page 1 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Question 1 (10 points )


Fill in the blanks with the appropriate word(s) 1- In a C program, to use the scanf function, you must include the _________________ file. 2- The ALU is a component of the _______________________ which is a main component of any digital computer. 3- Two computers can communicate over the phone line using a

______________________________ . 4- One Giga Byte is equal to _________________________________ bytes. 5- A ____________________ is a program which converts source code written in a high level language to machine code that can be executed by a computer. 6- A computer which is more powerful than a workstation, and is built to handle and receive requests from many computers connected to it using a network is called a _____________________ . 7- Many devices connected to a computer are considered as input devices. These include the mouse, the keyboard, and _______________________ . 8- The term _________________ is used to describe the use of many mediums of communication such as audio, video, and text in a single application or software. 9- (2AC0)16 = ( _____________________________________ )8 . 10- The main memory of a computer is composed of RAM which is temporary, and _______________ which is permanent storage.

Page 2 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Question 2 (15 Points)


Show the output of the following C program in the box below: #include<stdio.h> int main() { int A[]={6,5,2,3}; int B[2][4]; int M, N, W=0; for (M=0;M<2;M++) for (N=0;N<4;N++) B[M][N] = 3 * M + 2 ; for (M=0; M<2; M++) { N= 0; while (N<4) { printf("%4d%4d\n",A[N],B[M][N]); if (A[N] == B[M][N]) { W--; break; } W++; printf("W in Inner =%d\n",W); N+=1; } printf("W in Outer =%d\n",W); } return(0); } OUTPUT

Page 3 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Question 3 (15 points)


Show the output of the following C program in the box below: #include <stdio.h> int funcTest(int); float Z = 5.0; int main() { int F; int Q = 6; F = funcTest(Q); printf("mainnnnn\n"); printf("F=%d\n",F); printf("Z=%.2f\n",Z); Z++; F = funcTest(8); printf("mainnnnn\n"); printf("F=%d\n",F); printf("Z=%.2f\n",Z); return(0); } int funcTest(int P1) { static int C = 1; float Z = 7.5; int R; printf("funcTesttttt\n"); printf("C=%d\n",C); printf("Z=%.2f\n",Z++); printf("P1=%d\n",P1); C *= 5; printf("C=%d\n",C); R = P1 % 4; return(R); } OUTPUT

Page 4 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Question 4 (10 points)


Rewrite the following program into an equivalent one using a for loop instead of the dowhile loop. #include<stdio.h> int main() { int T =0, F=1; int M; do { scanf("%d",&M); printf("T=%d\n",T); if ( M < 0) F=0; T = T+2; }while (T < 10); return(0); }

Page 5 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Question 5 ( 15 points)
Write a function that accepts a two-dimensional array (matrix) of 5 by 5 integer elements. The function should use nested loops to calculate and return the sum of the elements which are not on the border of the matrix. The shaded elements in the following diagram shows those elements which are included in the sum.

Page 6 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Question 6 (15 Points)


Write a C program to output the following table into a file called TABLES.DAT for values of X, Y, and Z: TABLE Y 57.00 201.00 435.00 759.00 1173.00

X 3 6 9 12 15 Where Y = 5X2 + 3X + 3 and 1 Z = X +6 + 2 | X 100 |

Z 3.01 3.47 3.88 4.25 4.59

Use built-in (math) functions when appropriate in the formulas above. The first value of X is 3, last value of X is 15 and the increment of X is equals to 3 as shown above. Your output in the file TABLES.DAT should look like the above table.

Page 7 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 8 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Question 7 (20 Points)


Write a complete C program that asks the user for two strings stringOne and stringTwo. The program should find out whether or not stringOne appears in (is part of) stringTwo and if so, at what position. Your program should print an appropriate message in either case. Assume the maximum number of characters in each string is 99 and the first position is number 0. A sample run could be as follows: Enter first string: RAIN Enter second string: BAHRAINI The string is found in position 3

Page 9 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Page 10 PDF created with FinePrint pdfFactory trial version http://www.pdffactory.com

Вам также может понравиться