Question: 39. What is the value of variable s after execution of the program fragment below? char h[6] = wild; char p[6] = crazy; char s[10];

39. What is the value of variable s after execution of the program fragment below?

char h[6] = "wild";

char p[6] = "crazy";

char s[10];

strcpy(s, h);

strcat(s, p);

a. "wild crazy"

b. "wild craz"

c. "wildcrazy"

d. The value of s is undefined.

e. none of the above.

40. What is the value of the expression that follows?

strcmp("5", "49");

a. -1

b. 0

c. 1

d. <

e. >

41. Consider the following code fragment.

char str[10];

scanf("%s", str);

What will happen if scanf encounters the string "vivaciously" when scanning a value for str?

a. Since there is not enough room in str for the whole string, only "vivacious" will be stored in str.

b. Function scanf will store the entire string "vivaciously", even though there is insufficient space in str. The string will overflow str.

c. The program will abort with an error message.

d. Only "vivacious" will be scanned and stored, leaving "ly" on the input line.

e. None of the above.

42. What will be displayed by the statements below?

char s1[8] = "petunia", s2[9] = "marigold";

char tmp1[10], tmp2[20];

strcpy(tmp2, s1);

strcat(tmp2, s2);

strncpy(tmp1, &tmp2[5], 6);

tmp1[6] = '\0';

printf("b%s ", tmp1);

a. iamari

b. biamari

c. oldpet

d. boldpet

e. none of the above

43. In the fragment below, what is the minimum size of result required for successful and valid concatenation of "double " and "trouble"?

strcpy(result, "double");

strcat(result, "trouble");

a. 10

b. 13

c. 14

d. 15

e. none of the above

44. What is accomplished by the call to sprintf in the code fragment below?

char ans[20];

int num = 40;

sprintf(ans, "%d to %d", num, num + 10);

a. Nothing, the function name is misspelled.

b. It returns as its value the string "40 to 50".

c. It displays first the value of ans and then the string "40 to 50" (without the quote marks).

d. It aborts because the value of ans is garbage.

e. None of the above.

45. Which character marks the end of a string?

a. void

b. *

c. \0

d. \!

e. none of the above

46. What is the value of the expression that follows?

strcmp(dog, dogs);

a. -1

b. 0

c. 1

d. s

e. none of the above

47. To test whether a character is one of 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9, use the _______ standard library function.

a. isnumber

b. isnotalpha

c. isnumeric

d. isdigit

e. all of the above

48. Which function returns the length of a string, not including the null terminator?

a. numchar

b. strlen

c. charlen

d. countstr

e. none of the above

49. The data type returned from a string-building function is:

a. char

b. char *

c. string

d. string *

e. none of the above

50. The general utilities library is

a. stdutil

b. stdlibrary

c. stdutility

d. stdlib

51. The statement

printf( "%*.*f", 7, 2, 98.736 );

uses _______ for the precision, __________ for the field width and outputs the value 98.74 __________.

a. 7, 2, left justified

b. 2, 7, left justified

c. 2, 7, right justified

d. 7, 2, right justified

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!