cmpt130quiz3 - Quiz 3 Question 1 What is printed by char...

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

View Full Document Right Arrow Icon
Quiz 3
Background image of page 1

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

View Full DocumentRight Arrow Icon
Question 1 What is printed by char str1[100] = “bob”; puts(str1); printf(sizeof(str1)); printf(strlen(str1)); printf(“%d”,str1[2]); 100 3 bob 98 don’t memorize the ASCCI table but do know that characters are represented by numeric codes
Background image of page 2
Question 2 What is printed by int arr[] = {1,2,3}; int* p = arr; printf(“%d”, arr[2]); printf(“%d”, *++p) printf(“%d”,p); 3 2 an address I wouldn’t ask this, but you should know that pointers store addresses
Background image of page 3

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

View Full DocumentRight Arrow Icon
Question 3 print pt1's x coordinate printf("pt1.x = %d\n", pt1.x); typedef struct { int x; int y; }point; int main() { point pt1 = {1,1}; point pt2 = {2,2}; point pt3 = {3,3}; point arr[3]; arr[0] = pt1; arr[1] = pt2; arr[2] = pt3; return 0; } what is the value of arr.y[2] ? trick question: it's a compiler error what is the value of arr[2].y ? 3 (arr[2] is a struct equal to pt3)
Background image of page 4
Question 4 What does fopen return if it fails?
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.

Page1 / 8

cmpt130quiz3 - Quiz 3 Question 1 What is printed by char...

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