1/17
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is the main difference between C and C++?
C is a procedural programming language, while C++ supports both procedural and object-oriented programming, allowing for classes and objects.
How do you declare a variable in C/C++?
A variable in C/C++ is declared by specifying the data type followed by the variable name, e.g., int number;.
What are the basic data types in C/C++?
The basic data types in C/C++ include: 1. int 2. float 3. double 4. char 5. bool.
What is the syntax for a for loop in C/C++?
A for loop is declared as: for(initialization; condition; increment/decrement) { // code }.
What is the syntax for a while loop in C/C++?
A while loop is declared as: while(condition) { // code }.
What is the syntax for a do-while loop in C/C++?
A do-while loop is declared as: do { // code } while(condition);.
What is the difference between a for loop, while loop, and do-while loop?
A for loop is typically used for iterating over a range; a while loop checks the condition before execution, while a do-while loop guarantees that the block runs at least once since the condition is evaluated after execution.
How do you define a function in C/C++?
A function declaration includes the return type, function name, and parameters, e.g., int add(int a, int b);.
What are built-in functions in C/C++?
Built-in functions in C/C++ include standard libraries like printf, scanf, and math functions like sqrt.
What is the size of a variable and how does it vary?
The size of a variable in C/C++ can vary based on the data type and the system architecture. Common sizes are: int (usually 4 bytes), short (2 bytes), long (4 or 8 bytes depending on the system).
What type of values does a short integer hold and provide an example?
A short integer typically holds smaller integer values, e.g., short num = 32767;.
What type of values does a long integer hold and provide an example?
A long integer can hold larger integer values, e.g., long long num = 9223372036854775807;.
What are operators in C/C++?
Operators are symbols that perform operations on variables and values, including arithmetic (+, -, *, /), relational (==, !=, >, <), and logical (&&, ||) operators.
What are control structures in C/C++?
Control structures dictate the flow of execution in a program, including if-else statements, loops (for, while), and switch statements.
What are arrays in C/C++?
Arrays in C/C++ are collections of elements of the same data type stored in contiguous memory locations, e.g., int arr[5];.
What are pointers in C/C++?
Pointers are variables that store memory addresses, allowing for dynamic memory management and direct access to memory locations, e.g., int *ptr;.
What are the pillars of Object-Oriented Programming (OOP) in C++?
The pillars of OOP in C++ include: 1. Encapsulation 2. Abstraction 3. Inheritance 4. Polymorphism.
What are the pillars of Object-Oriented Programming (OOP) in C++?
The pillars of OOP in C++ include: 1. Encapsulation - bundling data and methods that operate on that data within one unit (class). 2. Abstraction - focusing on essential qualities rather than specific characteristics; hiding complex implementations. 3. Inheritance - the mechanism by which one class can inherit the properties and methods of another class, promoting code reusability. 4. Polymorphism - the ability of different classes to respond to the same function call in different ways, often implemented through method overriding and interfaces.