Programming C Flashcards

1
Q

What does printf do?

A

print commands write a string which is output on screen

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

What does scanf do?

A

Reads from the standard input stream until whitespace can read numbers and letters. Scanf requires variable declaration

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

What does fgets do?

A

similar to scanf but can read whitespace and only needs variable

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

How do we read whitespaces with scanf?

A

use the command %[^\n]

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

What is the purpose of escape sequences?

A

Allows the programmer to format the output

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

Give examples of format specifiers

A

%d (decimal integer)
%lf(double)
%Lf (long double)
%s (a string)

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

Define a variable in C

A

Areas in the memory where data is stored and accessed

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

What are some tips for naming variables?

A

Always begin with lowercase letters
Declare all variables at the start of the code

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

What does strlen do?

A

returns the length of the string (ignorning the string terminator)

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