exam2_All-final-B

exam2_All-final-B - Department of Computer Science and...

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

View Full Document Right Arrow Icon
1 Department of Computer Science and Engineering, Texas A&M University CPSC-206 (501-512) Structured Programming in C Fall 2011 – Exam 2 Question set B Name: __________________________ UIN: _________________________ TA: ____________________________ Lab Section: ___________________ True/False Questions: 1. When a function is called by value, the formal parameter is implemented as a local variable. T 2. The code below will print “Howdy!” for 10 times. F for(int i=0; i<=10; i++) printf("Howdy!\n"); 3. You can have more than one return statement in a function. T 4. As long as a function is not declared as void, it can be used as an operand in an expression. T --------------------------------------------------------------------------------------------------------- For the next 5 questions Choose correct answers (False(0) or True(1)) int i=3,j=4,k=1; double x=1.1, y=4.4; Example i<j+k Answer is 1 (True) Num Problem Answer 5 !i-j+4 F 6 -i+5*j>=k+1 T 7 x+k+7<y/k F 8 x!=y T 9 x||i && j-3 T ------------------------------------------------------------------------------------------------------------ 10. Square brackets are operators that increase the precedence of the operations inside them. F
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 11. The default statement is a requirement of a switch statement otherwise there could be an infinite loop. F 12. The code below is an infinite loop: T int i = 2; while(i = 1) { int j = 10; } 13. If you declare a variable inside of an if statement, then you can only use that variable in that if statement. T 14. Every function MUST return a value. F 15. The following two segment code is exactly same T X=10; Y=x>9?100:200; X=10; if(x>9) Y=100; else Y=200; 16. ‘d’+(‘Z’-‘z’) is ‘d’ F 17. A break statement will exit all loops: the inner and the outer loops. F 18. The null character is represented by ‘/0’ T/F 19. A for loop like the following: T int x; for(x = 1 ; x < 3; x++){ } works the same as: int x=1; while(x<3){ x++; } 20. Function prototypes must include the return type, function name, parameter types and parameter names. F 21. The following statements are different T
Background image of page 2
x= y/3-4*temp+1; X=(y/3)-4*(temp+1); 22. A function must be placed before the function call, if no function prototype is provided before the call. T 23. Function definitions can be nested. F 24. Local variables are stored on the run-time stack, created upon entry into its block and freed from memory upon exit. T 25. Exp1?exp2:exp3 stands for if Exp1 then Exp2 else Exp3 T 26. Two variables in different function can have the same variable name. T Multiple Choice Questions: 27. What is the output of the following segment code? B/D int a; for(a=0;a<5;a++); printf(“%d”,a); A. 0123 B. 01234 C. 012345 D. 5 E. None of the above 28. Find the error in the following segment code D int a=0; line 1 if(a) line 2 { printf(“t e s t \n”); line 3 }; line4 else { printf(“\ntest\n\n”); } A. Error at line 1 B. Error at line 2 C. Error at line 3
Background image of page 3

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

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

Page1 / 16

exam2_All-final-B - Department of Computer Science and...

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

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