wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Sharda fest 2024

Total questions: 25

Worksheet time: 50mins

Name
Class
Date
1.

1) What is the 16-bit compiler allowable range for integer constants?

a)
  1. 3.4e38 to 3.4e38

b)

.-32767 to 32768

c)

-32668 to 32667

d)

-32768 to 32767

2.

2) Study the following program:

  1. main()  

  2. {printf("javatpoint");  

  3. main();}  

  4. What will be the output of this program?

a)
  1. Wrong statement

b)

  It will keep on printing javatpoint

c)

   It will Print javatpoint once

d)

None of the these

3.

3) What is required in each C program?

a)

The program must have at least one function.

b)

The program does not require any function.

c)

  Input data

d)

     Output data

4.

4) What will this program print?

  1. main()  

  2. {  

  3.   int i = 2;  

  4.   {  

  5.     int i = 4, j = 5;  

  6.      printf("%d %d", i, j);  

  7.   }    

  8.   printf("%d %d", i, j);  

  9. }  

a)
  1. 4525

b)

2525

c)

4545

d)

None of the these

5.

5) Which of the following comment is correct when a macro definition includes arguments?

a)
  1. The opening parenthesis should immediately follow the macro name.

b)
  1. There should be at least one blank between the macro name and the opening parenthesis.

c)
  1. There should be only one blank between the macro name and the opening parenthesis.

d)
  1. All the above comments are correct.

6.

6) What is a lint?

a)
  1. C compiler

b)
  1. Interactive debugger

c)
  1. Analyzing tool

d)
  1. C interpreter

7.

7) What is the output of this statement "printf("%d", (a++))"?

a)
  1. The value of (a + 1)

b)
  1. The current value of a

c)
  1. Error message

d)
  1. Garbage

8.

8) Study the following program:

  1. main()  

  2. {  

  3.    char x [10], *ptr = x;  

  4.   scanf ("%s", x);  

  5.   change(&x[4]);  

  6. }  

  7.  change(char a[])  

  8.  {  

  9.    puts(a);  

  10.  }  

If abcdefg is the input, the output will be

a)
  1. abcd

b)
  1. abc

c)
  1. efg

d)
  1. Garbage

9.

9) Study the following program:

  1. main()  

  2. {  

  3.   int a = 1, b = 2, c = 3:  

  4.   printf("%d", a + = (a + = 3, 5, a))  

  5. }  

What will be the output of this program?

a)

6

b)

9

c)

12

d)

8

10.

10) What does this declaration mean?

  1. int x : 4;  

a)
  1. X is a four-digit integer.

b)
  1. X cannot be greater than a four-digit integer.

c)
  1. X is a four-bit integer.

d)
  1. None of the these

11.

11) Why is a macro used in place of a function?

a)
  1. It reduces execution time.

b)
  1. It reduces code size.

c)
  1. It increases execution time.

d)
  1. It increases code size.

12.

12) In the C language, the constant is defined _______.

a)
  1. Before main

b)
  1. After main

c)
  1. Anywhere, but starting on a new line.

d)
  1. None of the these.

13.

13) How many times will the following loop execute?

  1. for(j = 1; j <= 10; j = j-1)  

a)
  1. Forever

b)
  1. Never

c)

0

d)

1

14.

14) A pointer is a memory address. Suppose the pointer variable has p address 1000, and that p is declared to have type int*, and an int is 4 bytes long. What address is represented by expression p + 2?

a)
  1. 1002

b)

1004

c)

1006

d)

1008

15.

15) What is the result after execution of the following code if a is 10, b is 5, and c is 10?

  1. If ((a > b) && (a <= c))  

  2.         a = a + 1;  

  3. else  

  4.         c = c+1;  

a)
  1. a = 10, c = 10

b)
  1. a = 11, c = 10

c)
  1. a = 10, c = 11

d)
  1. a = 11, c = 11

16.

16) Which one of the following is a loop construct that will always be executed once?

a)
  1. for

b)
  1. while

c)
  1. switch

d)
  1. do while

17.

17) Which of the following best describes the ordering of destructor calls for stack-resident objects in a routine?

a)
  1. The first object created is the first object destroyed; last created is last destroyed.

b)
  1. The first object destroyed is the last object destroyed; last created is first destroyed.

c)
  1. Objects are destroyed in the order they appear in memory, the object with the lowest memory address is destroyed first.

d)
  1. The order is undefined and may vary from compiler to compiler.

18.

18) How many characters can a string hold when declared as follows?

  1. char name[20]:  

a)

18

b)

19

c)

20

d)
  1. None of the these

19.

19) Directives are translated by the

a)
  1. Pre-processor

b)
  1. Compiler

c)
  1. Linker

d)
  1. Editor

20.

20) How many bytes does "int = D" use?

a)

0

b)

1

c)
  1. 2 or 4

d)

10

21.

21) What feature makes C++ so powerful?

a)
  1. Easy implementation

b)

Reusing the old code

c)

Easy memory management

d)

All of the above

22.

22) Which of the following will copy the null-terminated string that is in array src into array dest?

a)
  1. dest = src;

b)
  1. dest == src;

c)
  1. strcpy(dest, src);

d)
  1. strcpy(src, dest);

23.

23) In the statement "COUT << "javatpoint" << end1;", end1 is a ___.

a)
  1. Extractor

b)
  1. Inserter

c)
  1. Manipulator

d)
  1. Terminator

24.

24) Each instance of a class has a different set of

a)
  1. Class interfaces

b)
  1. Methods

c)
  1. Return types

d)
  1. Attribute values

25.

25) How many instances of a class can be declared?

a)
  1. 1

b)
  1. 10

c)
  1. As per required

d)

None of the these