midtest1112_sem1 - N arroNAL U NrvpRSrrY o F S rNcnpoRB...

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

View Full Document Right Arrow Icon
NarroNAL UNrvpRSrrY oF SrNcnpoRB SCHOOL OF COMPUTING MID SEMtrSTER TEST AY201Il20L2 Semester 1 CS1O1OE - PROGRAMMING METHODOLOGY 1 October 2011 Time Allowed: 75 niinutes INSTRUCTIONS TO CANDIDATES 1. This test paper consists of TEN (10) questions and comprises ETEVEN (11) printed pages, inciuding this page. 2. This is an OPEN BOOK test. The maxirnum mark is 20. 3. Answer all questions by shading the letter corresponding to the most appropriate ans'r/er on the OCR form provided. 2 marks for each correct answer and no penalty for r,vrong answer. 4. Calculators are allowed, but not electronic dictionaries, laptops, PDAs, or other computing devices. 5. Do not look at the questions until you ale toid to do so. 6. Please write your matriculation number as well as shade your matriculation number clearly on the OCR form.
Background image of page 1

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

View Full DocumentRight Arrow Icon
1. Study the following program. #include <stdio . h> int swapl(int a, U); swap2(1nt b); swap3(int main ( vo id ) ( L a, b, result; scanf "7.d Tod" , &a, &b) ; result = swap3( swapt(a,b)'i.tO, swap2(b,a)%10 ) ; printf ("%d\n", result ); T6trlrn n. vt 1 I a, int b) { return swap2 (a, b) ; J swap2(int t returD swap3 (b, a) ; I { 1nt t; t a; a b; b t; a*10 + bi ) \4'hat is the output of the program when the user enters the foliowing input? 34 A. 33 B. 34 c. 43 D. 44 E. None of the above.
Background image of page 2
2. In Boolean logic, there is an operator called the exclusive OR (XOn) ',vhich will give the result of TRUE if and only if one of the operands is true. The following is the truth table for the XOR operator. A B AXORB FALSE TRUE Which of the following conditional expression is/are equivalent to the XOR operator? i. (!A ll !B) && (A ll B) ii. !((A && B) | I && !B)) iii. && !B) ll && B) ir'. !(A && B) && I I B) A. i only. B. i and ii only. C. i, ii and iii only. D. ii, iii and iv only. E. AII i, ii, iii and iv.
Background image of page 3

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

View Full DocumentRight Arrow Icon
3. Study the following program fragment.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/05/2012 for the course MATHEMATIC MA1505 taught by Professor Freudleong during the Spring '10 term at National University of Singapore.

Page1 / 11

midtest1112_sem1 - N arroNAL U NrvpRSrrY o F S rNcnpoRB...

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