Skip to main content
Contents Index
Dark Mode Prev Up Next
\(\newcommand{\N}{\mathbb N}
\newcommand{\Z}{\mathbb Z}
\newcommand{\Q}{\mathbb Q}
\newcommand{\R}{\mathbb R}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 3.7 Summary
Activity 3.7 .
Take a moment and think about the following:
What was your main take-away from today’s class?
What was the most confusing in today’s class?
Here is what we have learned:
printf()
is used to display a message to the screen. Example:
printf("This will be displayed on the screen!");
\n
starts a new line. Example:
printf("Hello!\nMy name is Petra!");
Quotation marks need to be "escaped", as in:
\"
,
\'
. Example:
printf("She said: \"Today it\'s Monday!\" ");
Loops are used to repeat instructions multiple times. Example:
int i;
for (i=0; i<3; i++) {
printf("Hello! ");
printf("Hi!\n");
}
Comments are important throughout your code. Comments can be included in your code by enclosing them in
/* ... */
or by using
//
. Example:
int main(void) {
int i; /* This is a comment. */
/* This is also a comment. */
/* A comment
can go over
multiple lines.
*/
for (i=0; i<3; i++) {
printf("Hello! "); // This comment ignores the remainder of the line.
printf("Hi!\n");
}
}