Computer Knowledge
Programming Fundamentals
2,381 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
-
LIFO
-
FIFO
-
LILO
-
None of these
A
Correct answer
Explanation
A stack is defined by its LIFO (Last In First Out) access pattern.
-
evaluate an arithmetic expression in postfix form
-
implement recursion
-
convert a given arithmetic expression in infix form to its equivalent postfix form
-
allocate resources (like CPU) by the operating system
C
Correct answer
Explanation
While stacks are used for expression evaluation and recursion, resource allocation (like CPU scheduling) is typically handled by queues to ensure fairness.
-
For … Next Statement
-
Do… While Statement
-
If …Then Statement
-
None of these
C
Correct answer
Explanation
In Visual Basic, the If...Then statement is a conditional selection statement used to execute code based on whether a condition is true or false. The other listed options, such as For...Next and Do...While, are looping or iteration statements rather than selection statements.
D
Correct answer
Explanation
In VB 6, a Sub procedure performs actions but does not return a value to the caller, unlike a Function procedure which returns a value.
-
String
-
Integer
-
Variant
-
Double
A
Correct answer
Explanation
In VB, the '$' suffix is a type-declaration character for String. Therefore, Triangle$ declares a function that returns a String.
-
Private Pseudo ( )
-
Private Function Pseudo ( )
-
Pseudo ( )
-
Function Pseudo@ ( )
-
Dim arrstu (20) as Integer
-
Dim arr(k) as Double
-
Dim arrstu ( 1 To 20) as String
-
Dim arrstu (2)
B
Correct answer
Explanation
Option B uses a variable 'k' inside the array declaration without it being defined or constant, which is invalid in standard VB array declarations.
-
Private Sub Month( )
-
Call Month ( )
-
Sub Dis_statement ( ) As Integer
-
Sub FindError (intsal as Integer)
D
Correct answer
Explanation
Option D is a valid Sub-procedure declaration with a parameter. Option A is also valid, but D is more descriptive of a procedure with parameters.
-
They use dynamic allocation for variable
-
They use static allocation for variable
-
Stacks are not available on all machines
-
It is not possible to implement recursion on all machine
A
Correct answer
Explanation
Recursion requires a new set of local variables for each function call, which is managed by dynamic allocation on the stack.
-
It increases the running time of programs
-
It makes program verification difficult
-
It increases the memory required for programs
-
It results in compiler generating larger machine code
B
Correct answer
Explanation
The goto statement creates non-linear control flow, making it difficult to trace the state of the program and verify its correctness.
-
Stdio.h
-
String.h
-
Iostream.h
-
None of these
C
Correct answer
Explanation
Iostream.h is the header file used in C++ to handle input and output functions.
-
Main()
-
Clrscr()
-
Getch()
-
None of these
A
Correct answer
Explanation
Main() is a master function required in all C++ program and program execution begin from the first statement of this function.
-
cin
-
cout
-
scanf()
-
printf()
B
Correct answer
Explanation
The cout statement is used to display the data on the screen in C++.
-
cin
-
scanf()
-
cout
-
printf()
A
Correct answer
Explanation
The cin statement is used to input data from the user in C++.
D
Correct answer
Explanation
Each case in switch statement should end with break statement. It transfers the control to the next statement or case.