C/C++ Programming Language Flashcards

To master all the concepts pertaining the use of C and C++ in software development.

1
Q

Makefiles

A

Yeah

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Relational Operator “>”

A

Greater Than

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

malloc( ) and calloc( ) functions, what are they and how are they different?

A

malloc( ) and calloc( ) are library functions that allocate memory dynamically. Accomplished using heap segmenting. Both functions return pointers to the beginning of the memory , or NULL if the allocation failed.

malloc( ) allocates a memory block of a given size (in bytes) and returns a pointer to the beginning of the block. The memory, however, is not initialized. If we try to access the content of the memory block then we’ll get garbage values.

calloc( ) allocates AND initializes memory blocks to zero. Additionally, calloc takes two arguments, the number of blocks to be allocated, and the size of each block.

In either case, any use of these functions must be followed with a call of free( ) in order to deallocate the memory, else you have a memory leak.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The form of the “if” conditional statement

A

if(condition){statements}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

4 phases of code development

A

1.Code 2.Save 3.Compile 4.Execute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The “Stack” As it pertains to the C language

A

Stack is a memory region where “local variables”, “return addresses of function calls” and “arguments to functions” are hold while C program is executed. CPU’s current state is saved in stack memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Relational Operator “<=”

A

Less than or Equal To

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

calloc

A

Yeah?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Relational Operator “!=”

A

Not Equal To

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Relational Operator “>=”

A

Greater than or equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Relational Operator “

A

Less Than

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

string

A

A string is a sequence of characters, more specifically it is an array of characters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

char

A

Used to specify individual characters (also bytes sometimes as they are only a single byte)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The “Heap” as it pertains to the C language

A

Heap is a memory region which is used by dynamic memory allocation functions at run time. Linked list is an example which uses heap memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

int

A

used to specify integer data types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does a Compiler do

A

A Compiler converts human readable code into machine code.

17
Q

double

A

Used top specify double precision floating point numbers

18
Q

Relational Operator “==”

A

Equal To

19
Q

Semaphore

A

Semaphore is a signaling mechansm (“I am done, you can carry on” kind of signal). For example, if you are listening to songs (assume it as one task) on your mobile and at the same time your friend calls you, an interrupt is triggered upon which an ISR signals the call processing task to wakeup.

A semaphore is a generalized mutex. In lieu of single buffer, we can split the 4 KB buffer into four 1 KB buffers (identical resources). A semaphore can be associated with these four buffers. The consumer and producer can work on different buffers at the same time.

20
Q

free () -memory

A

Yeah?

21
Q

What will the following command do? g++ helloworld.cpp -o hw

A

This command will compile the code in “helloworld.cpp” using G++ and output it with the name hw.out.

22
Q

Mutex

A

A mutex is a locking mechanism used to synchronize access to a resource. A mutex provides mutual exculsion, either producer or consumer can have the key (mutex) and proceed with their work. As long as the buffer is filled by producer, the conusmer needs to wait, and vice versa. At any point, only one thread can work with the entire buffer.

23
Q

bool

A

Stores Boolean Data, usually specific to C and C++ in software Development. You will usually not see this in embedded programming.

24
Q

“chaining”

A

pertains to the combination of strings and variables, similar to how Python allows combinations of outpus in a print statements. This method is contingent on the use of “cout” in the iostream library.

25
Q

strdup (something to do with strings I think)

A

Yeah

26
Q

Syntax for Modulo “%” operator

A

remainder = numerator % denominator;

27
Q

What is the “#” Operator in C/C++

A

Before a C program is compiled in a compiler, source code is processed by a program called preprocessor. This process is called preprocessing. Commands used in preprocessor are called preprocessor directives and they begin with “#” symbol.