15AG_Test1_Answers-1

15AG_Test1_Answers-1 - CIS 15AG Test 1 Answers: Chapters...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CIS 15AG Test 1 Answers: Chapters 1-5 Computer Science is no more about computers than astronomy is about telescopes. - Edsgar W. Dijkstra Chapters: 1 - 5 ______________________________________________________________________ 1. (10 Points ) You are given two files both containing machine language. The first file, let's call it FILE_1 has 161KB, and the second one, FILE_2, has 3 KB. Both files were created when working on a C program. (A) (2 Points ) Which one represents the object module? FILE_2 (B) (8 Points ) Why? Because File_2 has 3KB < 161KB, the size of FILE_1. An executable, i.e. FILE_1, contains the object module, FILE_2, and other object modules from the system's library. _______________________________________________________________________ _ 2. (10 Points ) Define a float variable named amount , an int variable num , and two char variables letter1 and letter1 , then code one statement that will read the following data stream entered by the user from the keyboard into the variables described above. A B 23.18 45 // Local Declarations float amount; int num; char letter1, letter2; // Statements scanf( "%c %c%f%d", &letter1, &letter2, &amount, &num ); 1 CIS 15AG Test 1 Answers: Chapters 1-5 one space must be used, otherwise letter2 will contain space and B would be invalid input for amount! _______________________________________________________________________ _ 3. (10 Points ) Predict the output. int num = 725; int a = 2; int b = 3; int c; c = a + 5 * b; // Write the output below printf( "%d\n", c ); // 2 + 5 * 3 = 2 + 15 = 17 num %= 100; printf( "%d\n", num ); // 725 % 100 is 25 the remainder num = 725; c = num / 100 * 100; // 725 / 100 * 100 = 7 * 100 = printf( "%d\n", c ); // 700 c = a + b++; // 2 + 3 is 5, then b changes to 4 printf( "%d %d\n", b, c ); // 4 5 b = 3; // 3 c = a + ++b; // first b changes to 4, then 2 + 4 printf( "%d %d\n", b, c ); // 4 6 a = 5; b = 7; c = !(a < b); // Write the output below printf( "%d\n", c ); // 0 (false) c = a > 0 && a < b; printf( "%d\n", c ); // 1 (true and true is true) c = b <= 0 || b >= a; printf( "%d\n", c ); // 1 (false or true is true) c = a < b || a > 0 && b != 9; // true or (anything) is true printf( "%d\n", c ); // 1 // (true and true) is true 2 CIS 15AG Test 1 Answers: Chapters 1-5 c = a < b && a > 0 || b != 9; // true or anything is true printf( "%d %d\n", b, c ); // 1 3 CIS 15AG Test 1 Answers: Chapters 1-5 _______________________________________________________________________ _ 4. (10 Points ) (A). Assume a, b, c, x1, and x2 have already been defined as double variables, and that a, b, and c have values ( a not zero). Write statements to calculate x1 and x2 using the formulae at page 301, project 64....
View Full Document

Page1 / 16

15AG_Test1_Answers-1 - CIS 15AG Test 1 Answers: Chapters...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online