1__Questions_Strings_11

1__Questions_Strings_11 - CIS 15BG Questions Chapter 11...

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

View Full Document Right Arrow Icon
CIS 15BG Questions Chapter 11: STRINGS 1. One of the following 6 fragments of code is incorrect. Which one? Why? (A) (B) int num = 10; int num; num = 10; (C) (D) char *ptr = "Tom"; char *ptr; ptr = "Tom"; (E) (F) char name[10] = "Tom"; char name[10]; name = "Tom"; 2. There are four mistakes in the following program fragment. Identify and correct at least two. // Local Definitions char title[30]; char author[] = Donald E. Knuth ; // Statements scanf( %30s , &title ); printf( %-35s , title ); 3. Which function(s) can be called to read a string from the standard input device? a. getstr b. fputs c. gets d. fgets e. puts f. sscanf g. scanf h. fscanf 1
Background image of page 1

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

View Full Document Right Arrow Icon
CIS 15BG Questions Chapter 11: STRINGS 4. What would be printed from the following code fragment? char str[] = "tomorrow "; char s1[20] = "is today" char s2[20] = "another day" char s3[50]; char *ptr; printf( "%d\n", sizeof( char ) ); // 1 printf( "%d\n", sizeof( int ) ); // 4 printf( "%d\n", sizeof( char *) ); // 4 printf( "%d\n", sizeof( int
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 3

1__Questions_Strings_11 - CIS 15BG Questions Chapter 11...

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

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