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
-
str
-
st
-
struct
-
stt
-
structure
C
Correct answer
Explanation
A struct in C programming language is a structured (record) type that aggregates a fixed set of labelled objects, possibly of different types, into a single object.
-
string.h
-
stdio.h
-
conio.h
-
stdlib.h
-
math.h
B
Correct answer
Explanation
Input and Output operations can also be performed in C using the C Standard Input and Output Library (cstdio, known as stdio.h in the C language). This library uses what are called streams to operate with physical devices such as keyboards, printers, terminals or with any other type of files supported by the system.
-
strcpy()
-
strstr()
-
strchr()
-
Both (2) and (3)
-
strcmp()
C
Correct answer
Explanation
This function determines the first occurrence of the character in the given string and if no match is found, then a NULL pointer is returned.
-
&
-
>>
-
delete
-
scope resolution operator (::)
-
new
D
Correct answer
Explanation
We cannot overload scope resolution operator (::) in C++.
-
malloc() is not used in C++.
-
malloc() is type-safe but new is not type-safe.
-
malloc() only allocates memory, while new operator allocates memory as well as constructs objects in C++.
-
Both (2) and (3)
-
None of these
C
Correct answer
Explanation
Yes, this is the main advantage of using new operator over malloc() in C++.
-
LINE
-
FILE
-
TIME
-
DATE
-
All of the above
E
Correct answer
Explanation
All are predefined C++ macros.
-
It is used to create an alias for a known data type.
-
typedef keyword can be used with unsigned char data type.
-
typedef keyword cannot be used to define an alias for a function.
-
Both (2) and (3)
-
None of these
C
Correct answer
Explanation
This is not true as we can also use typedef keyword to define an alias for a function in C++ and it can be used as function pointer.
-
<iostream></iostream><iostream>
-
<iomanip></iomanip><iomanip>
-
<fstream></fstream><fstream>
-
<stdio.h></stdio.h><stdio.h>
-
None of these
A
Correct answer
Explanation
This header file defines the cerr object in C++.
-
Static variables
-
Register variables
-
Extern variables
-
Auto variables
-
None of these
C
Correct answer
Explanation
Extern variables can be used to access in a file which is declared and defined in some other files, so these have a global scope outside the particular class and hence, they are called global variables.
-
This function instructs the compiler to insert copy of the code of that function at each point wherever that function is called at compile time.
-
To make a function inline, we should place inline keyword before that function.
-
Inline function reduces function calling overhead.
-
Inline function decreases the function size.
-
Inline function can make the header file size large.
D
Correct answer
Explanation
No, inline function may increase the function size of your program, so this is the false statement about inline function in C++.
-
Inline function cannot be used with small functions.
-
Inline function cannot be used in place of macros.
-
Inline function is not applicable for the complicated function.
-
Both (2) and (3)
-
All of the above
C
Correct answer
Explanation
This statement is true. In that case, the whole body of the function is placed when the function call is made every time in the program, so if the function is large it will affect the speed and memory of the program.
-
bool
-
void
-
wchar_t
-
enum
-
Both (3) and (4)
D
Correct answer
Explanation
It is a user-defined data type in C++.
-
We cannot put a semicolon after the namespace definition.
-
A namespace definition can be applied to multiple files.
-
We can use namespace in the program by scope resolution operator.
-
Only (1) and (2)
-
All of the above
E
Correct answer
Explanation
Yes, these all statements are true about namespace in C++.
-
declaration
-
executable
-
exception handler
-
declaration and executable
-
none of these
A
Correct answer
Explanation
In PL/SQL, all variables must be declared in declaration section.
-
0
-
NULL
-
Depends on the scale and precision of the datatype.
-
Without initialization, a variable cannot be used in the executable section of the block.
B
Correct answer
Explanation
In PL/SQL, any variable that is declared but not initialized automatically has a NULL value, regardless of its datatype. This is a fundamental PL/SQL behavior - uninitialized variables are NULL, not 0 or any default value. Option A is incorrect because 0 is not assigned automatically. Option C is wrong because the initial value is always NULL regardless of scale/precision. Option D is false - uninitialized variables can be used, though they will have NULL values which may affect logic.