Quiz-1

Question 1

Time: 00:00:00
The library function used to find the last occurrence of a character in a string is

strnstr()

strnstr()

laststr()

laststr()

strrchr()

strrchr()

strstr()

strstr()

Question 2

Time: 00:00:00
Identify which of the following are declarations
1 : extern int x;
2 : float square ( float x ) { ... }
3 : double pow(double, double);

1

1

2

2

3

3

1 & 3

1 & 3

Question 3

Time: 00:00:00
Which of the following statements are correct about an array?

1: The array int num[26]; can store 26 elements.

2: The expression num[1] designates the very first element in the array.

3: It is necessary to initialize the array at the time of declaration.

4: The declaration num[SIZE] is allowed if SIZE is a macro.

1

1

1,4

1,4

2,3

2,3

2,4

2,4

Question 4

Time: 00:00:00
Predict the output

#include<stdio.h>
void fun(int **p);

int main()
{
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};
int *ptr;
ptr = &a[0][0];
fun(&ptr);
return 0;
}
void fun(int **p)
{
printf("%d\n", **p);
}

1

1

2

2

3

3

4

4

Question 5

Time: 00:00:00
What will be the output of the program if the array begins at address 65486?

#include<stdio.h>
int main()
{
int arr[] = {12, 14, 15, 23, 45};
printf("%u, %u\n", arr, &arr);
return 0;
}

65486, 65486

65486, 65486

65486, 65488

65486, 65488

65486, 65490

65486, 65490

65486, 65487

65486, 65487

Question 6

Time: 00:00:00
What will be the output of the program?

#include<stdio.h>

int main()
{
char ch;
ch = 'A';
printf("The letter is ");
printf("%c", ch >= 'A' && ch <= 'Z' ? ch + 'a' - 'A':ch);
printf("\nNow the letter is ");
printf("%c\n", ch >= 'A' && ch <= 'Z' ? ch : ch + 'a' - 'A');
return 0;
}

Error

Error

The letter is A Now the letter is a

The letter is A Now the letter is a

The letter is a Now the letter is A

The letter is a Now the letter is A

None of the mentioned

None of the mentioned

Question 7

Time: 00:00:00
What will be the output of the program?

#include<stdio.h>
int main()
{
int i=-3, j=2, k=0, m;
m = ++i && ++j && ++k;
printf("%d, %d, %d, %d\n", i, j, k, m);
return 0;
}

 

-2, 3, 1, 1

-2, 3, 1, 1

2, 3, 1, 2

2, 3, 1, 2

1, 2, 3, 1

1, 2, 3, 1

3, 3, 1, 2

3, 3, 1, 2

Question 8

Time: 00:00:00
What will be the output of the program?

#include<stdio.h>
int main()
{
int i=4, j=-1, k=0, w, x, y, z;
w = i || j || k;
x = i && j && k;
y = i || j &&k;
z = i && j || k;
printf("%d, %d, %d, %d\n", w, x, y, z);
return 0;
}

1, 1, 1, 1

1, 1, 1, 1

1, 1, 0, 1

1, 1, 0, 1

1, 0, 1, 1

1, 0, 1, 1

1, 0, 0, 1

1, 0, 0, 1

Question 9

Time: 00:00:00
What will be the output of the program?


#include<stdio.h>
int main()
{
int i=3;
i = i++;
printf("%d\n", i);
return 0;
}

3

3

4

4

5

5

6

6

Question 10

Time: 00:00:00
Consider following given the code and predict its output

#include<stdio.h>

int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}

2, 1, 15

2, 1, 15

1, 2, 5

1, 2, 5

3, 2, 15

3, 2, 15

2, 3, 20

2, 3, 20

null
null

Buy Capgemini Pseudo Code Paid Materials

Join Capgemini Online Classes