exam3_s10

exam3_s10 - Exam 3 ECS 102 Dr. Baruch Spring 2010 Name:...

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

View Full Document Right Arrow Icon
Exam 3 ECS 102 Dr. Baruch Spring 2010 Name: problem points score 1 12 2 16 3 12 4 12 5 12 6 14 7 14 8 8 Total 100 1
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. Write a function printSomeStrings( char list[ ][80], int sizeOfList, int startindex, int stopindex); that will print the strings in the array list , beginning with the item at index startindex and ending with the item at index stopindex . Each item should be printed on a new line. If startindex is bigger than stopindex , nothing should be printed. If startindex is less than 0, printing should start at index 0. If stopindex is great than the last index of the list, then printing should stop at the last item of the list. Example: If list is 0 lion \ 0 1 tiger \ 0 2 bear \ 0 3 moose \ 0 4 rat \ 0 printSomeStrings(list,5, 1, 3) produces tiger bear moose printSomeStrings(list, 5, -3, 1) produces lion tiger 2
Background image of page 2
2. For each of the following, what will be the output ? (a) char s[] = "cookie"; char t[] = "carrot"; if (strcmp(s,t) > 0) printf("tasty\n"); else printf("yummy\n"); (b) char x[] = "brown"; char y[] = "fear"; y[0]=x[0]; printf("%s %s\n",x, y); (c) char a[] = "sugar"; char b[] = "water"; strcpy(b,a); printf("%s\n",a); printf("%s\n",b); (d) char university[] = "SYRACUSE"; char city[] = "Syracuse"; if (strcmp(university,city) == 0) printf("same\n"); else printf("different\n"); (e) char bodypart[20] = "leg"; printf("%d\n", strlen(bodypart)); (f) char z[] = "heart"; z[4]=’\0’; printf("%s\n",z); 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
int magic(int k) { int ans; if (k==1) ans = 1; else ans = k%2 + 2* magic(k/2); return ans; } (a) Circle all the lines of code that make up the base case for this recursion. (b) What will be the value of
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.

Page1 / 10

exam3_s10 - Exam 3 ECS 102 Dr. Baruch Spring 2010 Name:...

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