Exam 1
Exam 1
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
7. The command _________________ is used to copy the string x in the another string y.
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
1
2. (2AFE)16 + (1011100010111)2 =( )16
3. (11100110)2 * (11)2 = ( )2
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).
D) Find and print the youngest Student age (the smallest age) .