Converts a program written in C language into a language understandable by a computer (machine language)
Examples of C compilers
Turbo C
Borland C
Parts of a C program
Preprocessor Commands
Functions
Variables
Statements & Expressions
Comments
Preprocessor Commands
Commands that tell the compiler to do preprocessing before doing actual compilation
Functions
Main building blocks of any C Program, including the mandatory main() function
Variables
Used to hold numbers, strings and complex data for manipulation
Statements & Expressions
Expressions combine variables and constants to create new values, Statements are expressions, assignments, function calls, or control flow statements which make up C programs
Comments
Used to give additional useful information inside a C Program
C is a case sensitive programming language
C has a free-form line structure, with the end of each statement marked by a semicolon
Multiple statements can be on the same line in C
White spaces (tab, space) are ignored in C
Statements can continue over multiple lines in C
Primary data types in C
Integer
Character
Floating Point
Double precision floating point
Void
Integer Type
Whole numbers with a machine dependent range of values, including short int, int, and long int with signed and unsigned forms
Floating Point Types
Represent real numbers, with float, double, and long double providing increasing precision
Void Type
Used to specify the type of a function that does not return a value
Character Type
Represents a single character, with signed and unsigned forms
Size and range of data types on a 16-bit machine
Char/Signed Char
Unsigned Char
Int/Signed Int
Unsigned Int
Short Int/Signed Short Int
Unsigned Short Int
Long Int/Signed Long Int
Unsigned Long Int
Float
Double
Long Double
Declaration of variables
1. Tells the compiler the variable name
2. Specifies the data type the variable will hold
User-defined type declaration
Allows defining an identifier that represents an existing data type, which can then be used to declare variables
User-defined type declaration
typedef int salary;
typedef float average;
Enumerated data type
A user-defined data type where variables can only have one of the specified values
Enumerated data type
enum day {Monday, Tuesday, ..., Sunday};
enum day week_st, week_end;
C language instructions must strictly follow the predefined syntax rules
Keywords
Special words used exclusively by the C language, with their own meanings
C language character set
Letters (uppercase A-Z, lowercase a-z)
Digits (0-9)
Special characters
Whitespace (blank, tab, newline, etc.)
Identifiers
Names of user-defined variables, arrays, and functions, which must follow specific rules
Types of constants in C
Integer constants
Real constants
Single character constants
String constants
Integer constants
A sequence of digits
Identifier
The name of user-definedvariables, array and functions
Identifier
First character must be an alphabet (or underscore)
Identifier names must consists of only letters, digits and underscore
An identifier name should have less than 31 characters
Any standard C language keyword cannot be used as a variable name
An identifier should not contain a space
Types of constants in C
Integer Constants
Real Constants
SingleCharacter Constants
String Constants
Integer Constants
A sequence of digits, can be decimal, octal or hexadecimal
Octal Integer Constants
O26
O
O347
O676
Hexadecimal Integer Constants
OX2
OX8C
OXbcd
Ox
Real Constants
Numbers containing a fractionalpart, can also be represented in exponentialnotation