Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

CSE Pointers Quiz-1

Question 1

Time: 00:00:00
What is the output of following program?

  1. # include

  2. void fun(int x)

  3. {

  4. x = 30;

  5. }

  6. int main()

  7. {

  8. int y = 20;

  9. fun(y);

  10. printf("%d", y);

  11. return 0;

  12. }

30

30

20

20

Compile Error

Compile Error

Runtime Error

Runtime Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
Output of following program?

  1. # include

  2. void fun(int *ptr)

  3. {

  4. *ptr = 30;

  5. }

  6. int main()

  7. {

  8. int y = 20;

  9. fun(&y);

  10. printf("%d", y);

  11. return 0;

  12. }

20

20

30

30

Compile error

Compile error

Runtime error

Runtime error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

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

  1. #include<stdio.h>

  2. int main()

  3. {

  4. char *ptr;

  5. char string[] = "learn C from 2.com";

  6. ptr = string;

  7. ptr += 6;

  8. printf("%s",ptr);

  9. return 0;

  10. }

Compilation error

Compilation error

Runtime error

Runtime error

from 2braces.com

from 2braces.com

C from 2.com

C from 2.com

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

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

  1. #include<stdio.h>

  2. int main()

  3. {

  4. const int a = 5;

  5. const int *ptr;

  6. ptr = &a;

  7. ptr = 10;

  8. printf("%d\n", a);

  9. return 0;

  10. }

compilation error

compilation error

Garbage value

Garbage value

Address

Address

5

5

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

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

  1. #include<stdio.h>

  2. int main()

  3. {

  4. printf("%d", sizeof(void *));

  5. return 0;

  6. }

1

1

Compilation Error

Compilation Error

Runtime Error

Runtime Error

4

4

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
The output of the following program?

  1. #include<stdio.h>

  2. int main()

  3. {

  4. int *ptr;

  5. int x;

  6. ptr = &x;

  7. *ptr = 0;

  8. printf(" x = %dn", x);

  9. printf(" *ptr = %dn", *ptr);

  10. *ptr += 5;

  11. printf(" x = %dn", x);

  12. printf(" *ptr = %dn", *ptr);

  13. (*ptr)++;

  14. printf(" x = %dn", x);

  15. printf(" *ptr = %dn", *ptr);

  16. return 0;

  17. }

x = 0 *ptr = 0 x = 5 *ptr = 5 x = 6 *ptr = 6

x = 0 *ptr = 0 x = 5 *ptr = 5 x = 6 *ptr = 6

x = garbage value *ptr = 0 x = garbage value *ptr = 5 x = garbage value *ptr = 6

x = garbage value *ptr = 0 x = garbage value *ptr = 5 x = garbage value *ptr = 6

x = 0 *ptr = 0 x = 5 *ptr = 5 x = garbage value *ptr = garbage value

x = 0 *ptr = 0 x = 5 *ptr = 5 x = garbage value *ptr = garbage value

x = 0 *ptr = 0 x = 0 *ptr = 0 x = 0 *ptr = 0

x = 0 *ptr = 0 x = 0 *ptr = 0 x = 0 *ptr = 0

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

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

  1. #include<stdio.h>

  2. int main()

  3. {

  4. struct node { int a, b, c; };

  5. struct node num = {3, 5, 6};

  6. struct node *ptr = & num;

  7. printf("%d\n", *((int*)ptr + 1 + (3-2)));

  8. return 0;

  9. }

3

3

5

5

Compilation error

Compilation error

6

6

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
Consider a compiler where int takes 4 bytes, char takes 1 byte and pointer takes 4 bytes.

  1. #include<stdio.h>

  2. int main()

  3. {

  4. int arri[] = {1, 2 ,3};

  5. int *ptri = arri;

  6. char arrc[] = {1, 2 ,3};

  7. char *ptrc = arrc;

  8. printf("sizeof arri[] = %d ", sizeof(arri));

  9. printf("sizeof ptri = %d ", sizeof(ptri));

  10. printf("sizeof arrc[] = %d ", sizeof(arrc));

  11. printf("sizeof ptrc = %d ", sizeof(ptrc));

  12. return 0;

  13. }

sizeof arri[] = 3 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 4

sizeof arri[] = 3 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 4

sizeof arri[] = 12 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 1

sizeof arri[] = 12 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 1

sizeof arri[] = 3 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 1

sizeof arri[] = 3 sizeof ptri = 4 sizeof arrc[] = 3 sizeof ptrc = 1

sizeof arri[] = 12 sizeof ptri =8
sizeof arrc[] = 3 sizeof ptrc = 8

sizeof arri[] = 12 sizeof ptri =8
sizeof arrc[] = 3 sizeof ptrc = 8

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
Assume that float takes 4 bytes, predicts the output of the following the program.

  1. #include<stdio.h>

  2. int main()

  3. {

  4. float arr[5] = {12.5, 10.0, 13.5, 90.5, 0.5};

  5. float *ptr1 = &arr[0];

  6. float *ptr2 = ptr1 + 3;

  7. printf("%f ", *ptr2);

  8. printf("%d", ptr2 - ptr1);

  9. return 0;

  10. }

90.500000 3

90.500000 3

90.500000 12

90.500000 12

10.000000 12

10.000000 12

0.500000 3

0.500000 3

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00

  1. #include<stdio.h>

  2. int main()

  3. {

  4. int arr[] = {10, 20, 30, 40, 50, 60};

  5. int *ptr1 = arr;

  6. int *ptr2 = arr + 5;

  7. printf("Number of elements between two pointer are: %d.",

  8. (ptr2 - ptr1));

  9. printf("Number of bytes between two pointers are: %d",

  10. (char*)ptr2 - (char*) ptr1);

  11. return 0;

  12. }

Number of elements between two pointer are: 5. Number of bytes between two pointers are: 20

Number of elements between two pointer are: 5. Number of bytes between two pointers are: 20

Number of elements between two pointer are: 20. Number of bytes between two pointers are: 20

Number of elements between two pointer are: 20. Number of bytes between two pointers are: 20

Number of elements between two pointer are: 5. Number of bytes between two pointers are: 5

Number of elements between two pointer are: 5. Number of bytes between two pointers are: 5

Compiler Error

Compiler Error

Runtime Error

Runtime Error

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Completed

0/0

Accuracy

0%