Important Questions: Programming in C and Python
--- Programming in C ---
1. Basics & Fundamentals
• What are variables and data types in C? Explain with examples.
• What is the difference between =, ==, and === in programming?
• Explain constants in C. What is the use of #define?
2. Control Statements
• What is the difference between if, else if, and switch?
• Explain loops in C: for, while, and do-while.
• What is the use of break and continue?
3. Functions
• What is a function? What are function declaration, definition, and call?
• Explain call by value and call by reference in C.
• What is recursion? Give an example.
4. Arrays & Strings
• What is an array? How is a 2D array stored in memory?
• What are strings in C? How is a string different from a character array?
• Write a program to reverse a string without using library functions.
5. Pointers
• What is a pointer? How do you declare and use a pointer?
• Explain pointer arithmetic.
• What are dangling pointers and wild pointers?
• What is a pointer to a pointer?
6. Structures & Unions
• What is a structure? How is it different from a union?
• What is typedef and what is it used for?
• How to access structure members using pointers?
7. Dynamic Memory Allocation
• Explain malloc(), calloc(), realloc(), and free().
• What is a memory leak?
8. File Handling
• What are fopen(), fclose(), fscanf(), fprintf(), fread(), and fwrite()?
• Explain file modes in C.
--- Programming in Python ---
1. Basics
• What are variables and data types in Python?
• Why is Python called a dynamically typed language?
• What is the type() function used for?
2. Operators & Expressions
• What is the difference between /, //, and % in Python?
• Explain logical operators in Python.
3. Control Flow
• Explain if-elif-else with examples.
• What is the difference between for and while loops?
• What is list comprehension?
4. Data Structures
• What are lists? Why are they mutable?
• List methods: append(), extend(), insert(), pop().
• What are tuples? How are they different from lists?
• What is a dictionary? How to add, update, and delete key/value pairs?
• What are sets? Explain set operations: union, intersection, difference.
5. Functions
• What is a function?
• Explain default, keyword, and variable-length arguments.
• What is a lambda function?
6. Object-Oriented Programming
• What is a class? What is an object?
• Explain inheritance, polymorphism, and encapsulation.
• What are __init__ and self?
7. Modules & Packages
• What is a module? How do you import it?
• Difference between module and package.
8. File Handling
• How do you open, read, write, and close files in Python?
• Explain file modes: 'r', 'w', 'a', 'r+'.
9. Exception Handling
• What is an exception?
• Explain try, except, finally, and else.
10. Python Advanced Topics
• What is a generator?
• What are decorators?
• Explain map(), filter(), and reduce().