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. Positional Arguments

  2. Named Arguments

  3. Exit Sub

  4. None of these

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

This way of passing arguments to a procedure allows a special calling convention to be used that explicitly indicates the argument to be provided and the associated value

Multiple choice
  1. II and V only

  2. I, III and IV only

  3. I, II and V only

  4. II, III and V only

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

Multiple choice
  1. Only I

  2. Both I and II

  3. Both II and III

  4. Only IV

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

Multiple choice
  1. q = NULL; p->next = head; head = p;

  2. q->next = NULL; head = p; p->next = head;

  3. head = p; p->next = q; q->next = NULL;

  4. q->next = NULL; p->next = head; head = p;

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

Multiple choice
  1. 2

  2. 3

  3. 4

  4. 6

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

This is a register allocation problem using graph coloring principles. Tracking live variables: a=1 (a live), b=10 (a,b), c=20 (a,b,c), d=a+b (b,c,d) - a dead, e=c+d (c,d,e) - b dead, f=c+e (c,e,f) - d dead, b=c+e (b,c,e,f), e=b+f (b,e,f) - c dead, d=5+e (d,e,f) - b dead, return d+f (d,f). At the end, we need d and f alive simultaneously. Minimum registers needed = 3. We can allocate: R1=e (then f), R2=c (through multiple uses), R3=d (final). This satisfies all constraints with 3 registers. With only 2 registers, we'd need to spill a variable.