Lec-4 Flashcards

1
Q

What are the sizes of common data types in C?

A

char: 1 byte
int: 4 bytes
float: 4 bytes
double: 8 bytes
long: 8 bytes

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

What are the rules for identifiers in C?

A

Identifiers consist of A-Z, a-z, 0-9, and underscore, are case-sensitive, cannot start with a number, and cannot be a keyword.

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

What are best practices for naming identifiers?

A

Use meaningful names, limit to 31 characters, use lowercase for single syllables, and use underscore or camel case for multiple syllables.

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

What does the scanf() function do?

A

Reads input from standard input, uses format specifiers, and requires the address operator (&).

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

What does the printf() function do?

A

Outputs formatted text, uses conversion specifiers, and allows direct calculations within output.

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

What are some common format specifiers in C?

A

%c: Characters
%f: Floats
%lf: Doubles
%d: Integers
%s: Strings

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

How are constant variables declared in C?

A

Declared with ‘const’ keyword, must be initialized during declaration, and cannot be modified after initialization.

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

What is the purpose of the #define preprocessor directive?

A

Creates symbolic constants, replaces identifiers before compilation, and provides global constant definitions.

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

What are the advantages of using constants in C programming?

A

Improve code readability, eliminate ‘magic numbers’, and facilitate easier program maintenance.

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