C Programming Practice Questions
C Programming Practice Questions
Theory Questions
1. Inheritance
Inheritance is an OOP concept where a class (child) inherits properties and behaviors from another
2. Polymorphism
Polymorphism means having many forms. A function or object can behave differently based on the
context.
Example in C++:
class Shape { public: virtual void draw() { cout << "Drawing Shape"; } };
class Circle : public Shape { public: void draw() override { cout << "Drawing Circle"; } };
3. Operators
4. Keywords in C
Examples: int (e.g., int a = 10;), if (e.g., if(a > 0)), return (e.g., return 0;)
Low-level: Assembly
High-level: C, Python
7. One-Dimensional Array
8. Components of Flowcharts
Terminal: Oval
Process: Rectangle
Decision: Diamond
9. History of C
Developed by Dennis Ritchie in 1972 at Bell Labs. Used to develop UNIX OS.
Programming Questions
1. Check if a number is positive or negative
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if(num >= 0)
printf("Positive");
else
printf("Negative");
return 0;
}