1/8
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Basic Format
/* header comments */
preprocessor directives
main function heading
{
variable declarations
executable statements
return statement
}
other function definitions (optional)
/* sample output */
Preprocessor directives
#include <stdio.h>
#define NAME #
Main function heading
int main (void)
Variable Declarations
float variable names;
variable names only allow letters (abc), digits (123), underscores (_).
DONT start with #
DONT use reserved words
Executable Statements
printf(“statement”);
printf("That equals %f kilometers.\n", kms);
kms outside quotation marks replaces %f inside
scan(“%f”, &variable_name);
stores input as float, as the variable.
Assignment Statements: assigns a variable a value
variable name = value
Return Statement (for the end)
return (0);
printf Format Specifiers
%c single character (ASCII) 'X'
%d, %i signed integer (CAREFUL with %i for input)
%e, %E floating point, e-notation (E-notation: 8.16532e-11)
%g, %G floating point, decimal or e-notation (E-notation)
%f floating point, decimal notation
%s character string
%u unsigned integer
%x, %X unsigned hexadecimal integer (A,B,...)
%o unsigned octal integer
%p pointer (memory address)
%% percent sign
Escape Sequences (backslashes /)
\n new line
\t tab
\f form feed (new page)
\r carriage return (go back to column 1)
\b backspace
\\ backslash character
\" double quote
\' single quote