Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Q1: History of computing (5 points) 1. Assign each one of the following terms a number (1, 2, 3, 4 or 5) to indicate the hardware or software generation it belongs to (2.5 points) Generation Term 1 Card readers 1 Appearance of two types of programmers 3 Integrated circuits 5 Java 2 Magnetic disks 4 Workstations 2 COBOL and Lisp 3 Operating Systems 3 Separation between users and hardware 4 Apple, Sun and Dell 2. Is computing a mathematical discipline, a scientific discipline, or an engineering discipline? Explain? (1.5 points) Computing is mathematical, scientific and also engineering discipline. It has its roots in mathematical logic including Boolean algebra and numerical analysis. It is a scientific discipline as we build and test models of natural phenomena. As we design and build larger and larger computing systems, computing is also an engineering discipline 3. What is the difference between an assembler and a compiler? (1 point) An assembler translates assembly language code to machine language while a compiler translates high-level languages code to the machine language. Name: ………………………………………………………………………….. ID: ……………..……………. Section: ….…… Page 2 of 3 Q2: Conversions, arithmetic and representation of numbers: (8 points) 1. Convert the following hexadecimal number to decimal: A4B (1.5 points) 10*16*16 + 16*4 +11 = 2635 2. Convert the following octal number to binary: 7263 (1 point) Grouping: 7: 111 2: 010 6: 110 3: 011 111 010 110 011 3. Convert the following decimal number to base 6: 128 (1.5 points) 128/6 = 21, 2 21/6 = 3, 3 3/6 = 0, 3 322 4. What is the two’s complement representation of -12 if 5 binary digits are used to represent the numbers. (1.5 points) -12 = 2^5 – 12 = 20 convert 20 to binary to get the answer: 10100 Name: ………………………………………………………………………….. ID: ……………..……………. Section: ….…… Page 3 of 3 5. Perform the following binary addition: 10110 + 1110 (1 points) 100100 6. Perform the following octal subtraction: 1234 - 765 (1.5 points) 247 Q2: Data representation: (7 points) 1. The ____ compression ratio ___ is defined as the size of the compressed data divided by the size of the original data. 2. Three bits can represent up to ______ 8 ___________ unique things. 3. When representing numbers using ____signed magnitude ____, there are two representations for zero. 4. _____ Overflow ______ occurs when a calculated value cannot fit into the number of digits reserved for it. 5. The decimal point in a number, when working in other bases, is called the ___ radix_______ point. 6. A ____ character set ___ is a list of characters and the codes used to represent each one. 7. The extended ____ ASCII _______ character set contains 256 characters that support English but is not suited for international use. 8. ___ Sampling ____ is the process of periodically measuring the voltage of an audio signal. 9. An __ RGB _____ represents a color using three numbers that represent the relative contributions of three primary colors. 10. ____ Color depth ________ is the amount of data used to represent a color. 11. ____ Resolution ________ refers to the number of pixels used to represent a picture 12. A __ raster graphics _____ stores image information on a pixel-by-pixel basis. 13. ___ Spatial ____ compression removes redundant information within each frame of a video. PART II (Programming): Name:………………………………………………………………… ID: ..………. Section: .…… Page 2 of 4 PART II (Programming): Question Full Mark Your Mark Q1 6 Q2 10 Q3 4 TOTAL 20 Q1: (6 points) Expressions and rules of precedence 1. Translate the following mathematical formula into a C++ expression Make necessary declarations (3 points) Formula C++ expression (x, y, z, α and β are real numbers) || cos( ) sin( ) x yy x zxy + − = αβ // Declarations (1point) float x,y,z,alpha, beta; //Statement (2 points) Z=sqrt((x*cos(alpha)‐y*sin(beta))/abs(pow(x,y)+pow(y,x)) 2. Assume the following declarations (3 points) int a=12, b=4, c=10; float x=5.0, y; a. Evaluate the C++ expressions below (1 point) Expression Value Y = X ‐ C / B + 3.5 6.5 b. Indicate the order in which the operations in the following C++ expressions are executed (2 points) Y = sqrt ( A % ( B ‐ 1 ) / ( B + 1 ) ) 3142 Q2: (10 points) finding and correcting errors: 1. Circle at least five (5) errors in the following C++ program. (5 points) Errors that occur in the same line are counted as one error. Please note that Sterling formula is defined as follows: n!= e−nnn 2πn And there is a C++ function in cmath library exp (n)=en 1. #include <iostream> 2. #include <cmath> 3. 4. using namespace std 5. / This function calculates factorial of n using Sterling formula 6. int main{ 7. double Sterling, PI=3.14159; 8. int n; 9. 10. cout << “Please, enter n: “ ; 11. cin << n; 12. Sterling= exp(n)* -n pow(n)*sqrt(2*PI*n); 13. cout<< ”value of n! is:”<<setw(10)<<Sterling << endl; 14. return 0; 15. } 2. For each of the errors you circled above, rewrite the whole corrected statement in the table provided below according to the line number where it should be included (5 points) Error # line # Write the whole correct Statement 1. 4 Using namespace std; 2. 5 // This function calculates factorial of n using Sterling formula 3. 6 int main() 4. 11 cin>>n; 5. 12 sterling= exp(n)* pow(double(n),-n)*sqrt(2*PI*n); 6. 3 #include <iomanip> Q3: (4 points) Write in the table provided below, the exact output of the following program. Note: Each cell of the table represents one character location. #include <iomanip> #include <iostream> #include <string> using namespace std; int main() { string item1="hard disk", item2="mouse"; int num1= 10, num2=20; float totalPrice1=157,totalPrice2=15.557; cout<<fixed<<showpoint<<setprecision(1); cout<<num1<<"units of"<<item1<<"were sold\n"; cout<<setw(12)<<"Total price="<<setw(6)<<totalPrice1<<endl; cout<<setprecision(2); cout<<setw(4)<<num2<<setw(9)<<"units of"<<setw(6)<<item2<<" were sold\n"; cout<<setw(12)<<"Total price="<<setw(8)<<totalPrice2<<endl; cout<<endl; return 0; } 10unitsofharddiskweresold Totalprice=157.0 20unitsofmouseweresold Totalprice=15.56