Interview_Programming_for_Problem_Solving
Interview_Programming_for_Problem_Solving
1
1. Interview Questions with Answers(UNIT 1)
1. What are the main components of a computer system?
Answer:
The main components of a computer system include:
• Hardware is the physical, tangible part of a computer (e.g., CPU, RAM, monitor).
• Software is a set of instructions that tell the hardware what to do (e.g., Windows OS, MS
Word, C++ compiler).
• Compiler: Converts the entire high-level program into machine code before execution.
• Interpreter: Translates and executes the program line-by-line.
Example:
• C uses a compiler.
• Python uses an interpreter.
• Linker: Combines multiple object files and libraries into a single executable file.
• Loader: Loads the executable file into memory and prepares it for execution.
7. What is a flowchart? Name some commonly used symbols.
Answer:
A flowchart is a graphical representation of an algorithm.
Common symbols used:
(a) Start
(b) Read number
(c) If number % 2 == 0, then
• Print “Even”
(d) Else
• Print “Odd”
(e) End
Example:
# include < stdio .h >
int main () {
printf ( " Hello , World ! " ) ;
return 0;
}
• Keywords
• Identifiers
• Constants
• Operators
• Strings
• Special symbols
• A 2-D array is a matrix (table) of elements stored in rows and columns. Example:
int matrix [2][3] = {{1 , 2 , 3} , {4 , 5 , 6}};
Example:
void add ( int x , int y ) ; // x , y are formal arguments
add (5 , 10) ; // 5 , 10 are actual arguments
• Call by Value: Copies the actual value into the function’s formal parameter. Changes do
not affect the original variable.
• Call by Reference: Passes the address of the variable. Changes inside the function affect
the original variable.
struct Student s1 ;
s1 . roll = 101; // Dot operator
struct Student {
char name [20];
struct Date dob ; // Nested structure
};
Example:
void display ( struct Student s ) {
printf ( " % d " , s . roll ) ;
}
Initialization example:
int a = 10;
int * ptr = & a ; // ptr stores the address of a
Example:
int x = 20;
int * p = & x ;
printf ( " % d " , * p ) ; // prints 20