C-Programming Highlights
C-Programming Highlights
Console Input/Output Console Input/Output (cont) Data Types (cont) Derived Data Types
scanf() Read value/s character's ANSI Void Data Type Empty finite number of
format string) into input stream Boolean Type True or Function A self-contained
variable/s (type buffer as an False block of single or
must match) from integer. (safe) multiple statem‐
the input stream. putcha‐ Prints a single Primary Data Types ents.
Stops reading at r(int) character from an Pointers Special form of
Integer int Storing
the first whites‐ ANSI code variables for
Whole
pace. & prefix not integer to the holding other
Numbers
required for output stream variables’
Character char Refers to
arrays (including buffer. addresses.
all ASCII
strings.) (unsafe) Strings
character Unions The memory that
printf() Prints data fgets(‐ Reads a line from sets and we allocate to the
(formats defined strName, the input stream single largest data type
by the format length, into a string alphabets gets reused for all
string) as a string stdin); variable. (Safe) the other types
Long long Long
to the output present in the
puts("s Prints a string to integer
stream group.
tring") the output Floating float Refer to
Alternative Structures A collection of
stream. point all the
fgets(‐ Uses fgets to limit various different
real
strName, the input length, Data Types types of data type
number
then uses sscanf items
length,
Basic Floating-point, value or
stdin); to read the decimal
Data integer, double,
resulting string in Standard Library Functions
sscanf(); Type character point
place of scanf. #include<...>
Derived Union, structure, Double double Include
(safe)
Data array, etc (Long all large Header File Description
Type float) type of stdio.h Standard
numeric input/output
that do header file
not come
conio.h Console
under
input/output
floating
header file
point or
integer string.h String
related
Void void No value
functions
are defined
in this
header file
Standard Library Functions Commenting (cont) Looping (cont) Control characters (Escape
(cont) sequences)
/* Insert multiple-line comment do/while This loop will
string.h Contains general example: execute the code \a Alert (bell) character
functions used in block once, before \b Backspace
/*This is
C checking if the
a multiple \f Formfeed
math.h All math related condition is true,
line comment*/ then it will repeat \n New line
functions are
defined here the loop as long \r Carriage return
Conditional Statements as the condition is
time.h Contains time and \t Horizontal tab
true
clock related if used to specify a \v Vertical tab
functions block of code to be for Loops through a
block of code for a \\ Backslash
ctype.h All character executed, if a
specified condition specified amount \? Question mark
handling functions
is true of repetitions \' Single quote
are defined here
else used to specify a continue Breaks one \" Double quote
stdarg.h Variable argument
block of code to be iteration (in the
functions are \0 null
executed, if the loop), if a specified
declared here
condition occurs, \nnn Any octal ANSI
same condition is
signal.h Signal handling character code
false and continues with
functions are
the next iteration \xhh Any hexadecimal ANSI
declared here else if used to to specify a
in the loop character code
new condition to
setjmp.h Includes all jump
test, if the first break Skips rest of loop
functions Arithmetic Operators
condition is false contents and exits
locale.h Includes locale loop Operator Name Descri‐
switch Used instead of
functions ption
writing many
errno.h Includes error Keywords
if...else + Addition Adds
handling functions together
statements auto double int struct
assert.h Includes two
break Used to stop the break else long switch
diagnostic values
execution of more case enum register typedef
functions Subtra‐ Subtracts
code and case -
char extern return union
testing inside the ction one value
Commenting const float short unsigned from
block
// Insert continue for signed void another
single-line Looping * volatileMultip‐ Multiplies
default goto sizeof
comment lication two
while Loops through a block do if static while
example: of code as long as a values
Arithmetic Operators (cont) Format Specifiers (cont) Primitive Variable Types (cont) Primitive Variable Types (cont)
++ Increment Increases %u Unsigned decimal integer unsigned 2 0 to 65,535 Type Bytes Value
the value of a %x Unsigned hexadecimal short Range
variable by 1 integer (Norma‐
signed 2 -32,768 to
Decrement Decreases lized)
- %p Display a pointer short 32,767
- the value of a float 4 ±1.2×10-38
%% Print a % long 4 unsigned or
variable by 1 to
/ signed
compute, calculate, or add ±3.4×1038
Primitive Variable Types 8
statments can also be used double 8/4 ±2.3×10-
applicable but not limited to most unsigned 4 0 to 232-1 or 308
to
ARM, AVR, x86 & x64 instal‐ long / 264-1
Format Specifiers ±1.7×10308
lations 8
or alias to
%a Signed hexadecimal signed 4 -231 to 231-1
[class] [qualifier] float for
float / or -263 to 263-
long
[unsigned] type/void AVR
%c A character 8 1
name; long ARM: 8, AVR: 4,
%d or %i Signed decimal long 8 unsigned or
by ascending arithmetic double x86: 10, x64:16
integer long signed
conversion Qualifiers
%6d Print as a decimal unsigned 8 0 to 264-1
Integers const Flags variable as
integer, at least 6 long
Type Bytes Value type read-only (compiler
characters wide long
Range can optimise)
%e Signed decimal with signed 8 -263to 263-1
char 1 unsigned volatile Flags variable as
scientific notation
long
or signed type unpredictable
%f Signed decimal float long
unsigned 1 0 to 255 (compiler cannot
%6f Print as floating // signed is the default modifier optimise)
char
point, at least 6 of int and char data type
characters wide signed 1 -128 to
(allows + or - value)
char 127
%.2f Print as floating // unsigned only stores positive
point, 2 characters int 2/4 unsigned
values
after decimal point or signed
Floats
%6.2f Print as floating unsigned 2/4 0 to
point, at least 6 wide int 65,535 or
and 2 after decimal 231-1
point signed 2/4 -32,768 to
%g Shortest represent‐ int 32,767 or
ation of %f or %e -231 to
%o Unsigned octal 232-1
integer short 2 unsigned
%s Character string or signed