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
-
float, int pointer
-
float pointer, int pointer
-
float, int
-
float pointer, int
A
Correct answer
Explanation
The macro floatptr expands to float , so floatptr f1,f2 becomes float *f1,f2. Due to precedence, this declares f1 as float but f2 as float (only f1 gets the asterisk). For intptr (defined as int ), intptr p1,p2 becomes int *p1,p2, declaring p1 as int and p2 as int. Therefore f2 is float and p2 is int.
-
only from the innermost loop
-
only from the innermost switch
-
from all loops and switches
-
from the innermost loop or switch
D
Correct answer
Explanation
The break statement in C++ exits from the innermost loop or switch statement that contains it. It does not exit from all nested loops or switches simultaneously - only the immediately enclosing one. To exit from multiple levels, you would need multiple break statements or a different control structure like goto.
-
stdio.h
-
math.h
-
ctype.h
-
string.h
-
sequential
-
count
-
repetitive
-
incremental
-
Missing parentheses in return statement.
-
The function should be defined as int f(int a, int b).
-
Redeclaration of 'a'.
-
None of the above
C
Correct answer
Explanation
The function has a parameter named 'a', and then inside the function body, 'a' is redeclared as a local variable with 'int a;'. This creates a redeclaration error because you cannot declare a variable with the same name as a parameter in the same scope. Option C correctly identifies this as 'Redeclaration of a'. The parameter 'a' is already declared in the function signature, so declaring it again inside is a compilation error.
-
an operator
-
a label
-
a variable
-
a function
B
Correct answer
Explanation
The goto statement transfers control to a labeled statement within the same function. You use goto with a label like 'my_label:' and then 'goto my_label;' to jump to that point. Option B correctly states that goto causes control to go to 'a label'. It cannot jump to operators (A), variables (C), or functions (D) - only to labeled statements within the current function.
-
the loop in which it occurs
-
the block in which it occurs
-
the function in which it occurs
-
the program in which it occurs
D
Correct answer
Explanation
The exit() function in C++ terminates the entire program immediately, not just the current function or loop. It performs cleanup and ends program execution. Option D correctly states it causes exit from 'the program in which it occurs'. This is different from return, which only exits from the current function. The exit() function is defined in header and affects the whole program.
-
If-else statements
-
Looping statements
-
For/Next statement
-
GoTo Label statement
-
Select Case statement
A
Correct answer
Explanation
If-else branching statements are used to cause certain actions within a program if a certain condition is met.
-
Dim i as integerPrivate Sub Command1_Click ()i = 1Do until i > 5Print computer; ii = i + 1LoopEnd Sub
-
Dim i as integerPrivate Sub Command1_Click ()i = 1Do while i <= 5Print computer; ii = i + 1LoopEnd Sub
-
Dim i as integerPrivate Sub Command1_Click ()i = 1Do while i <= 8Print computer; ii = i + 1LoopEnd Sub
-
Dim i as integerPrivate Sub Command1_Click ()i = 1Do while i <= 8Print computer; ii = i + 1;LoopEnd Sub
-
Dim i as integerPrivate Sub Command1_Click ()i = 1Do while i <= 3Print computer; ii = i + 1;LoopEnd Sub
B
Correct answer
Explanation
This is the correct code.
-
computer
-
syntax error in function
-
compier
-
COMPIER
-
computpier
C
Correct answer
Explanation
This is the right answer.
-
Two dimensional array
-
Three dimensional array
-
Dynamic array
-
One dimensional array
-
Control array
D
Correct answer
Explanation
This is the correct answer.
-
IsMissing function
-
IsNull function
-
IsError function
-
TypeName function
-
IsObject function
B
Correct answer
Explanation
IsNull returns true if an expression does not contain any valid data.
-
IF-ELSE
-
DO-WHILE
-
FOR-NEXT
-
WHILE
A
Correct answer
Explanation
IF-ELSE is a conditional branching structure that executes different code blocks based on a condition. It does not repeat code execution. DO-WHILE, FOR-NEXT, and WHILE are all looping constructs that repeatedly execute code blocks.
-
Domain
-
Code
-
User info
-
Application specific information
-
Implemented code
E
Correct answer
Explanation
NSError object does not have implemented code.