wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PSC Quiz1

Total questions: 20

Worksheet time: 24mins

Name
Class
Date
1.

A function may have any number of return statements each returning different Values.Say True or False

a)

True

b)

False

2.

which keyword is used to create new names for datatypes

(a)  

3.

By considering a 32 bit processor,Give the size of the following Structure

struct value

{

int num[35];

float f;

char c;

};

a)

145

b)

144

c)

148

d)

150

4.

A Program under execution will be in which memory

a)

Cache Memory

b)

Secondary Memory

c)

None

d)

Main Memory

5.

#include<stdio.h>

main()

{ int x = 5;

if(x=5)

{

if(x=5) break;

printf("Hello");

}

printf("Hi");

}

a)

Hello

b)

Hi

c)

Compiler Error

d)

Logical Error

6.

All functions can be recursively called except the main function

a)

True

b)

False

7.

#include<stdio.h>

main()

{

char s[20] = "Hello\0Hi";

printf("%d %d", strlen(s), sizeof(s));

}

a)

5,9

b)

9,20

c)

5,20

d)

5,5

8.

Similarity between a structure, union and enumeration,

a)

A - All are helpful in defining new variables

b)

B - All are helpful in defining new data types

c)

C - All are helpful in defining new pointers

d)

D - All are helpful in defining new structures

9.

What actually get pass when you pass an array as a function argument?

a)

A - First value of elements in array

b)

B - Base address of the array

c)

C - All value of element in array

d)

D - Address of the last element of array

10.

What is the output of following program?

# include <stdio.h>

void fun(int x)

{

    x = 30;

}

 

int main()

{

  int y = 20;

  fun(y);

  printf("%d", y);

  return 0;

}

a)

30

b)

compiler error

c)

run time error

d)

20

11.

Code to change the 3rd array value to 50 using pointers

int main()

{

int a[] = {10,20,30};

int *p = a;

----------------------;

}

a)

p+3 = 50

b)

*(p+3) = 50

c)

*p+2 = 50

d)

*(p+2) = 50

12.

Output of following program?

# include <stdio.h>

void fun(int *ptr)

{

    *ptr = 30;

}

 

int main()

{

  int y = 20;

  fun(&y);

  printf("%d", y);

 

  return 0;

}

a)

20

b)

Compiler Error

c)

30

d)

Run time Error

13.

#include <stdio.h>

int main()

{

int *ptr;

int x;

ptr = &x;

*ptr = 0;

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

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

*ptr += 5;

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

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

(*ptr)++;

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

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

return 0;

}

a)

x = 0

*ptr = 0

x = 5

*ptr = 5

x = 6

*ptr = 6

b)

x = garbage value

*ptr = 0

x = garbage value*ptr = 5

x = garbage value

*ptr = 6

c)

x = 0

*ptr = 0

x = 5

*ptr = 5

x = garbage value

*ptr = garbage value

d)

x = 0

*ptr = 0

x = 0

*ptr = 0

x = 0

*ptr = 0

14.

Assume that float takes 4 bytes, predict the output of following program.

#include <stdio.h>

 

int main()

{

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

    float *ptr1 = &arr[0];

    float *ptr2 = ptr1 + 3;

 

    printf("%f ", *ptr2);

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

 

   return 0;

}

a)

90.500000 3

b)

90.500000 12

c)

10.00000 12

d)

0.50000 12

15.

The reason for using pointers in a Cprogram is

a)

A

Pointers allow different functions to share and modify their local variables.

b)

B

To pass large structures so that complete copy of the structure can be avoided.

c)

C

Pointers enable complex “linked" data structures like linked lists and binary trees.

d)

D

All Answers are correct

16.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

int a[3] = {1, 2, 3};

int *p = a;

printf("%p\t%p", p, a);

}

a)

a) Same address is printed

b)

b) Different address is printed

c)

c) Compile time error

d)

d) Nothing

17.

Assuming a 32 bit processor predict the output of the following program

int main()

{

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

int *ptri = arri;

printf("%d ", sizeof(arri));

printf("%d ", sizeof(ptri));

return 0;

}

a)

3 3

b)

12 12

c)

4 4

d)

12 4

18.

Is the NULL pointer same as an uninitialised pointer?

a)

Yes

b)

No

19.

Predict the Output of the Following

#include<stdio.h> 

void f(int p, int q) 

  p = q; 

  *p = 2; 

int i = 0, j = 1; 

int main() 

  f(&i, &j); 

  printf("%d %d \n", i, j); 

  getchar(); 

  return 0; 

}

a)

(A) 2 2

b)

(B) 2 1

c)

(C) 0 1

d)

(D) 0 2

20.

Predict output of following program

Predict the output of the following code

#include <stdio.h>

 

int fun(int n)

{

    if (n == 4)

       return n;

    else return 2*fun(n+1);

}

 int main()

{

   printf("%d ", fun(2));

   return 0;

}

a)

4

b)

8

c)

16

d)

12