FUNDAMENTALS OF PROGRAMMING (INTRO, CHAP 3-4)

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/29

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:12 PM on 9/18/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

30 Terms

1
New cards

comments

/* */

2
New cards

Preprocessor directive - tells the computer to load contents of a certain file

#include <stdio.h>

3
New cards

entry point

int main ()

4
New cards

prints the string of characters

printf(““)

5
New cards

what ends a statement?

semicolon (;)

6
New cards

escape character

\

7
New cards

newline character

\n

8
New cards

how do you exit a function?

return 0;

9
New cards

Statements executed one after the other in the order written

Sequential execution

10
New cards

– When the next statement executed is not the next one in

sequence

– Overuse of goto statements led to many problems

Transfer of control

11
New cards

– All programs written in terms of 3 control structures

• Sequence structures: Built into C. Programs executed

sequentially by default

• Selection structures: C has three types: if, if/else, and

switch

• Repetition structures: C has three types: while, do/while

and for

Bohm and Jacopini

12
New cards

– Graphical representation of an algorithm

– Drawn using certain special-purpose symbols connected by

arrows called flowlines

– Rectangle symbol (action symbol):

• Indicates any type of action

– Oval symbol:

• Indicates the beginning or end of a program or a section of code

Flowchart

13
New cards

Connect exit point of one control structure to entry point of

the next (control-structure stacking)

– Makes programs easy to build

Single-entry/single-exit control structures

14
New cards

– Used to choose among alternative courses of action

Selection structure

15
New cards

– Indicates decision is to be made

– Contains an expression that can be true or false

– Test the condition, follow appropriate path

Diamond symbol (decision symbol)

16
New cards

– Takes three arguments (condition, value if true, value if

false)

– Our pseudocode could be written:

printf( "%s\n", grade >= 60 ? "Passed" :

"Failed" );

– Or it could have been written:

grade >= 60 ? printf( “Passed\n” ) :

printf( “Failed\n” );

Ternary conditional operator (?:)

17
New cards

– Compound statements with declarations

Block

18
New cards

– Caught by compiler

Syntax errors

– Caught by compiler

19
New cards

Logic errors:

– Have their effect at execution time

– Non-fatal: program runs, but has incorrect output

– Fatal: program exits prematurely

20
New cards

– Loop repeated until counter reaches a certain value

– Definite repetition: number of repetitions is known

– Example: A class of ten students took a quiz. The grades

(integers in the range 0 to 100) for this quiz are available to

you. Determine the class average on the quiz

Counter-controlled repetition

21
New cards

Many programs have three phases:

– Initialization: initializes the program variables

– Processing: inputs data values and adjusts program variables

accordingly

– Termination: calculates and prints the final results

22
New cards

Can be used instead of c+=1

Increment operator (++)

23
New cards

Can be used instead of c-=1

Decrement operator (--)

24
New cards

Variable is changed before the expression it is in is evaluated

Preincrement (++c or —c)

25
New cards

Expression executes before the variable is changed

Postincrement(c++ or c--)

26
New cards

Definite repetition: know how many times loop will execute

– Control variable used to count repetitions

Counter-controlled repetition

27
New cards

– Indefinite repetition

– Used when number of repetitions not known

– Sentinel value indicates "end of data"

Sentinel-controlled repetition

28
New cards

Format when using for loops

for ( initialization; loopContinuationTest; increment ){

statement}

29
New cards

Format when using while loops

while ( loopContinuationTest ) {

statement;

increment;

}

30
New cards

Format when using do-while loops

do {

statement;

} while ( condition );