exam2_All-final-A

exam2_All-final-A - 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 A Name: __________________________ UIN: _________________________ TA: ____________________________ Lab Section: ___________________ True/False Questions: 1. Square brackets are operators that increase the precedence of the operations inside them (F) 2. Exp1?exp2:exp3 stands for if Exp1 then Exp2 else Exp3 (T) 3. The null character is represented by ‘/0’ (T/F) 4. 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++; } 5. ‘d’+(‘Z’-‘z’) is ‘d’ (F) 6. The following statements are different (T) x= y/3-4*temp+1; X=(y/3)-4*(temp+1); --------------------------------------------------------------------------------------------------------- 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;
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 Example i<j+k Answer is 1 (True) Num Problem Answer 7 -i+5*j>=k+1 (T) 8 x+k+7<y/k (F) 9 x!=y (T) 10 !i-j+4 (F) 11 x||i && j-3 (T) ------------------------------------------------------------------------------------------------------------ 12. A break statement will exit all loops: the inner and the outer loops. F 13. The default statement is a requirement of a switch statement otherwise there could be an infinite loop. F 14. The code below will print “Howdy!” for 10 times. F for(int i=0; i<=10; i++) printf("Howdy!\n"); 15. The code below is an infinite loop: T int i = 2; while(i = 1) { int j = 10; } 16. If you declare a variable inside of an if statement, then you can only use that variable in that if statement. T 17. Every function MUST return a value. F 18. When a function is called by value, the formal parameter is implemented as a local variable. T 19. Function prototypes must include the return type, function name, parameter types and parameter names. F 20. A function must be placed before the function call, if no function prototype is provided before the call. T 21. As long as a function is not declared as void, it can be used as an operand in an expression. T 22. Two variables in different function can have the same variable name. T 23. You can have more than one return statement in a function. T 24. Function definitions can be nested. F 25. Local variables are stored on the run-time stack, created upon entry into its block and freed
Background image of page 2
3 from memory upon exit. T Multiple Choice Questions: 26. 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; 27. What is the output of the following segment code? (D) char a,b[2],c=’f’; c=(c>=’A’&&c<=’F’)?c - (‘a’ - ‘A’):c; printf(“%c”,c); A. C B. c C. F D. f E. None of the above 28. 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 29. If x has the value 5, the expression
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.

This note was uploaded on 03/19/2012 for the course GEOG 305 taught by Professor Prout during the Spring '08 term at Texas A&M.

Page1 / 16

exam2_All-final-A - 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