cmpt130aep_quiz

cmpt130aep_quiz - #include stdio.h #include math.h int...

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

View Full Document Right Arrow Icon
Quiz
Background image of page 1

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

View Full DocumentRight Arrow Icon
Question 1 What is 2310 in binary? 10101 (16 + 4 + 2 + 1) What is 1100002 in decimal? 32 + 16 = 48
Background image of page 2
Question 2 The program that converts a C file into machine language is called a. Pre-processor b. Compiler c. Linker d. Assembly language
Background image of page 3

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

View Full DocumentRight Arrow Icon
Question 3 What do the printf statements shown below print? printf( “**%6.1f**” ,123.456); ** 123.5** printf( “**%4s%-4c**” , “bob” , ‘a’ ); ** boba ** printf( “**.2%f**” ,1.23456); **.21.23456**
Background image of page 4
Question 4 Write a function that returns (not prints) the square of its float parameter Now use your function in a main function to print the square of 22.854 float square( float x) { return x * x; } int main() { printf( “%f” , square(22.854)); return 0; }
Background image of page 5

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

View Full DocumentRight Arrow Icon
Question 5 Identify at least 5 things wrong with the program shown below Which is intended to calculate the difference between the square roots of of two values entered by the user
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #include stdio.h #include math.h int main() { float num1; float 2num scanf(%f, &num1); scanf(%f, 2num); printf( difference = %d , sqrt(number1) sqrt(); return 0; } illegal variable name incorrect format specification missing & missing argument missing ; undeclared variable name ... and no instructions . .. Question 6 Both the functions shown below calculate the area of a rectangle Explain which function is likely to be more void rectArea1( float width, float height) { printf( %f , width * height); } floa t rectArea2( float width, float height) { return width * height; } The function that returns a value can be used as part of other calculations, whereas the void function cannot...
View Full Document

This note was uploaded on 12/23/2011 for the course CMPT 120 taught by Professor Cuikerman during the Fall '08 term at Simon Fraser.

Page1 / 7

cmpt130aep_quiz - #include stdio.h #include math.h int...

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

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