Basic Codes

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

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:48 PM on 9/20/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

9 Terms

1
New cards

Basic Format

/* header comments */

preprocessor directives

main function heading

{

variable declarations

executable statements

return statement

}

other function definitions (optional)

/* sample output */

2
New cards

Preprocessor directives

#include <stdio.h>

#define NAME #

3
New cards

Main function heading

int main (void)

4
New cards

Variable Declarations

float variable names;

  • variable names only allow letters (abc), digits (123), underscores (_).

  • DONT start with #

  • DONT use reserved words


5
New cards

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.


6
New cards

Assignment Statements: assigns a variable a value

variable name = value

7
New cards

Return Statement (for the end)

return (0);

8
New cards

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

9
New cards

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