Beginning C Programming For Dummies Cheat Sheet
Beginning C Programming For Dummies Cheat Sheet
By Dan Gookin
The best way to learn programming is to start with a fundamental language like C.
Nearly every other popular language today borrows from C. Whether you’re
curious about programming, need to pass a college course, or want to start your
own app business, learning C is the right place to begin.
#include <stdio.h>
int main()
{
return(0);
}
Traditionally, the program begins with preprocessor directives plus prototypes.
The #include statements bring in header files, such as stdio.h, the standard
input/output header file.
The primary function in all C code is main(), which is the first function that’s run
when the program starts. The main() function is an int function, so it must return
an integer value. All the function’s statements are enclosed in curly brackets, or
braces.
C Language Keywords
The C language keywords represent the core of the language. With the C11
revision to the language, several new keywords have been added. They’re shown
with leading underscores in the following table:
read://https_www.dummies.com/?url=https%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fwww.dummies.com%2Fprogramming%2Fc%2Fbeginning-c-programming-for-dummies-c… 1/5
7/20/2020 Beginning C Programming For Dummies Cheat Sheet
You use only a few of the C language keywords in your code. Some of
them, you’ll probably never use.
read://https_www.dummies.com/?url=https%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fwww.dummies.com%2Fprogramming%2Fc%2Fbeginning-c-programming-for-dummies-c… 2/5
7/20/2020 Beginning C Programming For Dummies Cheat Sheet
Ensure that you choose the proper variable type for the values you
need to store.
The _Bool type stores only two values, 0 and 1, which can represent
TRUE or FALSE or On or Off or any binary condition.
The char variable type stores character values, though it can also be
used to store tiny integers.
Any type of value, from the very large to the very small, and any
fractional values are stored in the float and double types.
Remember to use int values for functions that generate integers, such
as getchar(). It’s easy to assume that the function returns a char value
because of the function’s name.
read://https_www.dummies.com/?url=https%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fwww.dummies.com%2Fprogramming%2Fc%2Fbeginning-c-programming-for-dummies-c… 3/5
7/20/2020 Beginning C Programming For Dummies Cheat Sheet
Conversion
What It Displays
Character
%% The percent character (%)
%c A single character (char)
%d Integer value (short, int)
Floating-point value in scientific notation using a little E
%e
(float, double)
Floating-point value in scientific notation using a big E
%E
(float, double)
%f Floating-point value in decimal notation (float, double)
Substitutes %f or %e, whichever is shorter (float,
%g
double)
Substitutes %f or %E, whichever is shorter (float,
%G
double)
%i Integer value (short, int)
%ld Long integer value (long int)
%o Unsigned octal value, no leading zero
%p Memory location in hexadecimal (*pointer)
%s String (char *)
Unsigned integer (unsigned short, unsigned int, unsigned
%u
long)
Unsigned hexadecimal value, lower case (short, int,
%x
long)
Unsigned hexadecimal value, capital letters (short, int
%X
long)
read://https_www.dummies.com/?url=https%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fwww.dummies.com%2Fprogramming%2Fc%2Fbeginning-c-programming-for-dummies-c… 4/5
7/20/2020 Beginning C Programming For Dummies Cheat Sheet
read://https_www.dummies.com/?url=https%3A%2F%2F2.zoppoz.workers.dev%3A443%2Fhttps%2Fwww.dummies.com%2Fprogramming%2Fc%2Fbeginning-c-programming-for-dummies-c… 5/5