Computer C and C++

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

flashcard set

Earn XP

Description and Tags

ALL THEORY INCLUDED

Last updated 6:56 PM on 7/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

18 Terms

1
New cards

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.

2
New cards

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;.

3
New cards

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.

4
New cards

What is the syntax for a for loop in C/C++?

A for loop is declared as: for(initialization; condition; increment/decrement) { // code }.

5
New cards

What is the syntax for a while loop in C/C++?

A while loop is declared as: while(condition) { // code }.

6
New cards

What is the syntax for a do-while loop in C/C++?

A do-while loop is declared as: do { // code } while(condition);.

7
New cards

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.

8
New cards

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);.

9
New cards

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.

10
New cards

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).

11
New cards

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;.

12
New cards

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;.

13
New cards

What are operators in C/C++?

Operators are symbols that perform operations on variables and values, including arithmetic (+, -, *, /), relational (==, !=, >, <), and logical (&&, ||) operators.

14
New cards

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.

15
New cards

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];.

16
New cards

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;.

17
New cards

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.

18
New cards

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.