What is the effect of the following code?
main() { int a[4] = {25, 16};
printf(“%d %d”, a[0] & a[1], a[1]|a[2]) ; }
Option A. 16 16
Option B. Syntax error because of invalid operator symbol
Option C. 25 16
Option D. Syntax error because of invalid array initialization
True Answer A
Explanation :
What is the effect of the following code?
main() { int a[4] = {25, 16};
printf(“%d %d”, a[0] & a[1], a[1]|a[2]) ; }
The index of an array starts from 1.
Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer B
Explanation :
False: Array index always start with 0
The index of an array starts from 1.
Which of the following is the correct way to define a two dimensional array?
Option A. int a[ ][4];
Option B. int b[2, 4];
Option C. int c[2][ ];
Option D. int d[ ] [ 4] = {{1, 3, 5, 7}, {2, 4, 6, 8}};
True Answer D
Explanation :
Which of the following is the correct way to define a two dimensional array?
Which of the following function can be used to find the first occurrence of a given string in another string?
Option A. strchr( )
Option B. strrchr( )
Option C. strstr( )
Option D. strnset( )
True Answer C
Explanation :
strstr is a C standard library string function as defined in string.h. strstr() has the function signature char * strstr(const char *haystack, const char *needle); which returns a pointer to a character at the first index where needle is in haystack, or NULL if not present.
Which of the following function can be used to find the first occurrence of a given string in another string?
What will be the output of the following code segment if Hello there is given as input?
char a[20];
scanf("%s", a);
printf("%s", a);
Option A. Hello there
Option B. Hello
Option C. "Hello there"
Option D. "Hello"
True Answer B
Explanation :
What will be the output of the following code segment if Hello there is given as input?
char a[20];
scanf("%s", a);
printf("%s", a);
Which of the following function is more appropriate for reading in a multi-word string?
Option A. printf();
Option B. scanf();
Option C. gets();
Option D. puts();
True Answer C
Explanation :
Which of the following function is more appropriate for reading in a multi-word string?
A. printf();
B. scanf();
C. gets();
D. puts();
Answer: Option C
Explanation:
gets(); collects a string of characters terminated by a new line from the standard input stream stdin
Which of the following function is more appropriate for reading in a multi-word string?
Consider the statement given below:
int a[5] = {1, 2, 3, 4, 5}, *p = a;
Which printf statement will print the value of fourth element of the array?
Option A. printf("%d ", *(p + 3));
Option B. printf("%d", p[4]);
Option C. printf("%d ", a + 3);
Option D. printf("%d ", *a + 3);
True Answer A
Explanation :
Consider the statement given below:
int a[5] = {1, 2, 3, 4, 5}, *p = a;
Which printf statement will print the value of fourth element of the array?