Computer Knowledge

Programming Fundamentals

2,611 Questions

Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.

Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references

Programming Fundamentals Questions

Multiple choice
  1. 1,2,3,4

  2. 1, 2

  3. 2, 3, 4

  4. 3, 4

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

CFL’s are not closed under complementation. Regular and recursive languages are closed under complementation.

Multiple choice
  1. fails as L can overflow

  2. fails as L can take on a non-zero value when the lock is actually available

  3. works correctly but may starve some processes

  4. works correctly without starvation

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Multiple choice
  1. 0

  2. 1

  3. 2

  4. 3

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In the above code, total number of spills to memory is 2.

Multiple choice
  1. It cannot have subroutine call instruction.

  2. It can have subroutine call instruction, but no nested subroutine calls.

  3. Nested subroutine calls are possible, but interrupts are not.

  4. All sequences of subroutine calls and also interrupts are possible.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Stack pointer register holds the address of top of stack, which is the location of memory at which the CPU should resume its execution after servicing some interrupt or subroutine call. So if SP register not available then no subroutine call instructions are possible.

Multiple choice
  1. At most one activation record exists between the current activation record and the activation record for the main.

  2. The number of activation records between the current activation record and the activation record for the main depends on the actual function calling sequence.

  3. The visibility of global variables depends on the actual function calling sequence.

  4. Recursion requires the activation record for the recursive function to be saved on a different stack before the recursive fraction can be called.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Activation record is the contiguous memory locations where the data needed by the program is kept so at most one activation record exist between current activation record & the record for the main.

Multiple choice
  1. I,II, and IV only

  2. II, III, and IV only

  3. II and IV only

  4. IV only

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation
int main(){
    int *A[10], B[10][10];
    int c[] = {12, 11, 13, 14};

   A[2] = C;

   A[2][3] = 15;

   B[2][3] = 15;

   printf("%d %d', A[2][0], A[2][3]);
   getchar();
}
Multiple choice
  1. call swap (x,y)

  2. call swap (&x,&y)

  3. swap (x,y) cannot be used as it does not return any value

  4. swap (x,y) cannot be used as the parameters are passed by value

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Here the function takes the arguments by value.

$\rightarrow$       Option (A) sends parameter by value but only the local variable a & b will be exchanged but not the actual variables x & y so incorrect. $\rightarrow$ Option (B) is incorrect sending address of x & y . $\rightarrow$ Option (C) swap (x,y) is usable there is no need to return. $\rightarrow$ Option (D) is the opposite statement of option (A), it says that the values are passed by value so won't swap so the option is correct.