exam2-2009spring - CSE 1311 Exam #2 Name: March 30, 2009 If...

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

View Full Document Right Arrow Icon
CSE 1311 Name: Exam #2 March 30, 2009 If you show your work, you should CLEARLY indicate what your answer is. Problems 1–14 are worth 5 points each. ASCII values of alphanumeric characters 32 space 51 3 70 F 89 Y 108 l 33 ! 52 4 71 G 90 Z 109 m 34 " 53 5 72 H 91 [ 110 n 35 # 54 6 73 I 92 \ 111 o 36 $ 55 7 74 J 93 ] 112 p 37 % 56 8 75 K 94 ^ 113 q 38 57 9 76 L 95 _ 114 r 39 58 : 77 M 96 115 s 40 ( 59 ; 78 N 97 a 116 t 41 ) 60 < 79 O 98 b 117 u 42 * 61 = 80 P 99 c 118 v 43 + 62 > 81 Q 100 d 119 w 44 , 63 ? 82 R 101 e 120 x 45 - 64 @ 83 S 102 f 121 y 46 . 65 A 84 T 103 g 122 z 47 / 66 B 85 U 104 h 123 { 48 0 67 C 86 V 105 i 124 | 49 1 68 D 87 W 106 j 125 } 50 2 69 E 88 X 107 k 126 ~ strlen() returns the length of a string, minus the terminating null. For example, strlen("book") has a value of 4. It is in the library string.h
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. What does the following program print? #include <stdio.h> int fc(int [], int); int main(void) { int data[4] = {4, 3, 0, 2}; printf("The sum is %d\n", fc(data, 4) ); } int fc(int a[], int cols) { int i = 0; int sum = 0; while(i < cols) { if(a[i] || sum) { sum += a[i]; printf("%d\n", sum); } i++; } return sum; }
Background image of page 2
2. What does the following program print? #include <stdio.h> void fc(int [][3]); void printArray(int [][3]); int main(void) { int data[3][3] = {{ 7, 11, 15}, {23, 25, 29}, {35, 42, 46}}; fc(data); printArray(data); } void fc(int data[][3]) { int i, k; for(i = 0; i < 3; i++) for(k = 0; k < 3; k++) if(data[i][k] % 5 != 0) data[i][k] = 0; } void printArray(int data[][3]) { int i, k; for(i = 0; i < 3; i++) { for(k = 0; k < 3; k++) printf("%3d", data[i][k]); printf("\n"); } }
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. What does the following program print? #include <stdio.h> #include <string.h> void fc(char []); int main(void) { /* 01234567890 */ char text[] = "gwippans"; fc(text); printf("%s\n", text); } void fc(char str[]) { int i = 0; char temp; int len = (int) strlen(str); while(i < len/2) { if(str[i] < ’k’) { temp = str[i]; str[i] = str[len - i - 1]; str[len - i - 1] = temp; } i++; } }
Background image of page 4
4. What does the following program print? #include <stdio.h>
Background image of page 5

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

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

This note was uploaded on 09/12/2011 for the course JAVA 2312 taught by Professor Darinbrezeale during the Spring '11 term at University of Texas at Austin.

Page1 / 16

exam2-2009spring - CSE 1311 Exam #2 Name: March 30, 2009 If...

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

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