0% found this document useful (0 votes)
48 views7 pages

Exam 1

Uploaded by

r4h45pygxd
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)
48 views7 pages

Exam 1

Uploaded by

r4h45pygxd
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/ 7

Question 1: Choose the correct answer (10X1.

5=15 points)
1. ………….. loses its content when the power is turned off.
A) ROM B) BIOS C) RAM D) secondary memory
2. Dot matrix printer is considered ____________printer

A)impact B) non-impact C) compact D) None of them


3. The maximum unsigned value can be stored in 32 bits.
A) 232 B) 232 - 1 C) 231 D) 231 - 1

4. By what means is an “object code” produced?


A) Linker B) Compiler C) CPU D) None of them
5. Memory containing 215 bits is equivalent to memory of size _____________
A) 2 KB B) 4 KB C) 6 KB D) 8 KB

6. In C language, __________command is used to stop the loop


A) stop(); B) break; C) break(); D) continue;

7. The command _________________ is used to copy the string x in the another string y.

A) strcpy(x,y) B) strcpy(y,x) C) srtcopy(x,y) D) strcopy(y,x)

8. Which of the following loops will NEVER stop?


A) int i=10; do { ++i; } while (i < 10); B) int i=10; while (i<10) { i--; }
C) int i=10; do { --i; if (i==10) break; } while D) None of the above
(i<10);
9. Which of the following is not valid variable name?

A) _X2 B) X2_ C) if D) A2B

10. To input value for a defined string variable named X, we can use ________ command.

A)X=
1 getc(); 2 B)3 X=gets();4 5 C) gets(X);
6 7 D) scanf("%c",X);
8 9 10

Question 2: True or false (10X1=10 points)


1. C language is low level language. ( )
2. Characters are stored in the memory as numbers. ( )
3. program variables are referred to memory locations where a data can be stored. ( )
4. In C language, "%c" is used when you want to print string value. ( )
5. The command strcmop(x,y); is used to compare the string x with a another string y. ( )
6. In C language, the result of the casting operation (int)0.99 is 1. ( )
7. A trackpad provides the same functionality as a mouse. ( )
8. ASCII code uses 2 byte to represent each character. ( )
9. The binary value 11111011 is equivalent to the decimal value -5. ( )
10. Word processing programs are considered application software. ( )

Question 3: Solve the following: (3X5=15 points)

1. Convert a decimal number (-122)10 to its binary form ( )2

1
2. (2AFE)16 + (1011100010111)2 =( )16

3. (11100110)2 * (11)2 = ( )2

Question 4: (10X2=20 points)


Consider the following declarations, What is the output of the following statements?
int i=4,j=5, k= 3, a=0,b=2;
float z=543.342;
char ch= ‘B’;
The statements The output
1. printf( “%d”, floor(z-100) );
2. printf( “%d”, (int)z );
3. printf( “%6.2f”, z );
4. printf("%-4c",ch);
5. printf("%d",ch);
6. printf( “%d”, a++ * (a +b) );
7. int x=12;
switch(x%5){
case 1:printf("one");break;
case 2:printf("two");
case 3:printf("three");break
case 4:printf("four");}
8. if(0){printf("Yes");}
else{ printf("No");}
9. i=5;
While(1){ i=i*2; if(i>10)break; }
Printf("%d",i);
10. for (int i=1;i<3;){
printf("%d\t", i++ );}

2
Question 5: (10 points)
1. Write a program that calculates the squares and cubes of the numbers from 0 to 10 and below is a
sample of how the output should look:

Question 6 :Write a C code statements for doing the following: (10 points)
Assume that, there is an array named num is declared as:
int numbers[10]={23,22,2,3,66,78,65,54,88,98};
1. Compute and print the average for the values of the numbers array . (4 points)

2. Sort the values of the numbers in descending order. See figure#1. (6 points)

3
Question 7 : (20 points)
2 3 4 5
1.Write a C program computing the equation: R= x/1! + x /2! + x /3! + x /4! + x /5!
The
A factorial value for positive integer n is:
n! = 1 for n =0
n! = n*(n-1)*(n-2)*……..*1 for n >0
program should contain the following :
1. Declaration for a function computing the factorial. (5 points)
2. Declaration for a function computing the power . (5 points)
3. Declaration for the main function that enables the user to input the value of x and calls the
factorial and power functions to compute the result of the equation. (10 points)

4
5
Question #8 : Write a C function to perform the following: (10 points)
Assume that, there is an array named numbers is declared as:
int numbers[10]={23,22,2,3,66,78,65,54,88,98};

1. Write a function to sort the values of the numbers in descending order as shown in figure 1. The
function header should declared as void sort(int numbers[],int size);

23 98
22 88
2 78
3 66
66 SORT 65
78 54
65 23
54 22
88 3
98 2

Figure 1

6
Question #9 : Write a C code segment to perform the following: (15
points)

Assume a program manipulating Student data (name, address and age ), Write a C code
segments to do the following:

A) Define a structure type Student with data (name, address and age).

B) Declare an array of 5 elements of type Student.

C) List (print) all Student whose address is “Gaza”.

D) Find and print the youngest Student age (the smallest age) .

You might also like