Computer Languages Are The Languages Through Which The User Can Communicate With The Computer by Writing Program Instructions
Computer Languages Are The Languages Through Which The User Can Communicate With The Computer by Writing Program Instructions
Source Code Compiler Object Code Linker Executable Code User Screen
CPU
Sample.obj Sample.exe
Sample.c
stdio.h
List of ERRORS
Header Files
4
Brief History of C
• The C programming language was developed in the Bell Labs of AT&T
by an employee called Dennis Ritchie between 1969 and 1973 while
working on Unix operating system. He created this language
using ALGOL, BCPL, and B the languages that were used before C was
created.
• Ritchie added many powerful features to C and used it to further
develop the UNIX operating system. American National Standards
Institute (ANSI) in 1983, formed a committee to provide a
comprehensive definition to the C language and thus came into
existence the new ANSI C language with better features.
What is C Character set?
1
What does C Character Set contains?
Alphabets
- C Language supports all alphabets of English. It supports
both UPPERCASE & lowercase letters
Digits
- C Language supports 10 digits to construct numbers. Those
10 digits are 0,1,2,3,4,5,6,7,8,9
Special Symbols
- C supports a rich set of special symbols that include symbols
to perform mathematical operations, condition checking,
white space, back space, etc… 2
Commonly used Special Symbols with ASCII Values
3
C Tokens:
In C programs, each word and punctuation is referred to as a token.
C Tokens are the smallest building block or smallest unit of a C program.
Keywords
• Keywords are pre-defined words in a C compiler.
• Each keyword is meant to perform a specific function in a C program.
• Since keywords are referred names for compiler, they can’t be used as
variable name.
• C language supports 32 keywords which are given below.
C Identifiers
• Identifier refers to name given to entities such as variables, functions,
structures etc.
Syntax:
const type constant_name;
• TYPES OF C CONSTANT:
• Integer constants
• Real or Floating point constants
• Octal & Hexadecimal constants
• Character constants
• String constants
• Backslash character constants
By definition, a constant is a quantity that does not change
throughout the execution of a program.
Integer Constants
An integer constant is an integer quantity which contains a
sequence of digits.It should not have a decimal point. Blanks
and commas are not allowed within an integer constant.An
integer constant can be either +ve or -ve. The constant must lie
within the range of the declared data type (including qualifiers
long,short etc.).
Example of valid integer constants:- 976 8987 5 -25 etc.
String Constants
1. A string constant is a collection of characters enclosed
in double quotations “”
2. It may contain alphabets, digits, special characters and
blank space.
Example: “Circuits Today123”
Datatypes:
Void Types:
The void type has no values. It is used to represent the type of function. The
type of function is said to be void when it does not return any value to the calling
function.
Variables in C
• A variable is nothing but a name given to a storage area that our
programs can manipulate.
• A variable definition tells the compiler where and how much storage to
create for the variable.
• A variable definition specifies a data type and contains a list of one or
more variables of that type as follows −
Syntax:
type variable_list;
Ex:int i, j, k;
char c, ch;
float f, salary;
double d;
type variable_name = value;
printf(“%X”, variableOfXType);
• where %X is the format specifier in C. It is a way to tell the compiler
what type of data is in a variable
scanf()
• The scanf() method, in C, reads the value from the console as per the
type specified.
scanf(“%X”, &variableOfXType);
• where %X is the format specifier in C.
• It is a way to tell the compiler what type of data is in a variable
• & is the address operator in C, which tells the compiler to change the
real value of this variable, stored at this address in the memory.
C – Operators
• The symbols which are used to perform logical and mathematical
operations in a C program are called C operators.
• These C operators join individual constants and variables to form
expressions.
• Operators, functions, constants and variables are combined together
to form expressions.
• Consider the expression A + B * 5. where, +, * are operators, A, B are
variables, 5 is constant and A + B * 5 is an expression.
Expressions
• An expression is a combination of operators, constants and variables.
An expression may consist of one or more operands, and zero or more
operators to produce a value.
Precedence and Associativity
• The symbols which are used to perform logical and mathematical
operations in a C program are called C operators.
• These C operators join individual constants and variables to form
expressions.
• Operators, functions, constants and variables are combined together
to form expressions.
• Consider the expression A + B * 5. where, +, * are operators, A, B are
variables, 5 is constant and A + B * 5 is an expression.
Different types of operators
• Arithmetic operators
• Assignment operators
• Relational operators
• Logical operators
• Bit wise operators
• Conditional operators (ternary operators)
• Increment/decrement operators
• Special operators
Assignment
Operators
Relational
Operators
Logical Operators
big = a > b ? (a > c ? a : c) : (b > c ? b : c) ;
Increment/decrement operators
Operator Precedence in C
Operator precedence determines which operator is evaluated first when an expression has more than one operators.
Operators Associativity