SlideShare a Scribd company logo
C - Programming
Unit 1
Introduction to ‘C’ Language
1/12/2021 MR.RAVVINDRA SALUNKE
1.1 History
1.2 Basic Structure of ‘C’ Program
1.3 Language Fundamentals
1.3.1 Character Set, Tokens
1.3.2 Keywords and Identifiers
1.3.3 Variables and Data Types
1.4 Operators
1.4.1 Types of operators
1.4.2 Precedence and associativity
1.4.3 Expression
1/12/2021 MR.RAVVINDRA SALUNKE
 Developed in 1972 by Dennis Ritchie at AT&T (American Telephone & Telegraph) bell
laboratories, U.S.A.
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
https://developerinsider.co/download-turbo-c-for-windows-7-8-
8-1-and-windows-10-32-64-bit-full-screen/
OR
Any other link from google
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
Practical Explanation
1/12/2021 MR.RAVVINDRA SALUNKE
Assignment No 1 (Date- 08 Dec. 2020)
Q. 1. Write a short note on History of C Language
Q. 2. Write full form of following
a. BCPL b. ANSIc. ISO
Q. 3. Write a c program to display Hello World.
Q. 4. Write a c program to display addition of two numbers
Note:
1. Write this assignment in C Programing notebook
2. Take a sequential photos of your assignment & create pdf
file and send it on
email bbaca2020.21@gmail.com
3. Last date of submission 10 Dec. 2020
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
- Character set
- Tokens
- Keywords and identifiers
- Variables and data types
1/12/2021 MR.RAVVINDRA SALUNKE
Character Set
Source Character Set
Capital
Alphabets
Small
Alphabets
0-9
Digits
Special
Symbols
White
Space
Character
Execution Character Set
Backslash or Escape
Sequence Character
A-Z a-z 0-9
30 Symbol 11
1/12/2021 MR.RAVVINDRA SALUNKE
Alphabets ASSCI Value
A 65
B 66
C 67
D 68
E 69
F 70
G 71
H 72
I 73
Alphabets ASSCI Value
J 74
K 75
L 76
M 77
N 78
O 79
P 80
Q 81
R 82
Alphabets ASSCI Value
S 83
T 84
U 85
V 86
W 87
X 88
Y 89
Z 90
Capital Alphabets- A-Z
1/12/2021 MR.RAVVINDRA SALUNKE
Alphabets ASSCI Value
a 97
b 98
c 99
d 100
e 101
f 102
g 103
h 104
i 105
Alphabets ASSCI Value
j 106
k 107
l 108
m 109
n 110
o 111
p 112
q 113
r 114
Alphabets ASSCI Value
s 115
t 116
u 117
v 118
w 119
x 120
y 121
z 122
Small Alphabets- a-z
1/12/2021 MR.RAVVINDRA SALUNKE
Alphabets ASSCI Value
0 48
1 49
2 50
3 51
4 52
5 53
Alphabets ASSCI Value
6 54
7 55
8 56
9 57
Digits 0-9
1/12/2021 MR.RAVVINDRA SALUNKE
Alphab
ets
ASSCI
Value
Represents
! 32 Exclamation mark
“ 34 Quotation mark
# 35 Number sign
$ 36 Dollar Sign
% 37 Percent sign
$ 38 Ampersand
Alpha
bets
ASSCI
Value
Represents
( 40 Left parenthesis
) 41 Right
parenthesis
* 42 Asterisk
+ 43 Plus sign
Special Characters -
1/12/2021 MR.RAVVINDRA SALUNKE
Alphab
ets
ASSCI
Value
Represents
‘ 44 Comma
- 45 Minus sign
. 46 Period
/ 47 Slash
: 58 Colon
; 59 Semicolon
< 60 less then sign
= 61 Equal sign
> 62 Greater than sign
Alpha
bets
ASSCI
Value
Represents
? 63 Question mark
@ 64 at symbol
[ 91 Left bracket
 92 Black slash
] 93 Right bracket
^ 94 Caret
_ 95 Under score
{ 123 Left brace
| 124 Vertical bar
1/12/2021 MR.RAVVINDRA SALUNKE
Alphab
ets
ASSCI
Value
Represents
} 125 Right brace
~ 126 Tilde
1/12/2021 MR.RAVVINDRA SALUNKE
Constant Represents
b Blank space
 Back slash
n New line
f Form feed
0 Null
v Vertical tab
t Horizontal tab
’ Single quote
r Carriage return
Constant Represents
a Alarm(bell)
? Question mark
1/12/2021 MR.RAVVINDRA SALUNKE
1. Certain ASCII character are unprintable which means
they are not displayed on the screen or printer.
2. Those character performed other function aside from
displaying text.
3. Examples are - backspacing , moving to a newline or ,
ringing a bell this are used in output statements.
4. Execution character set are always represented by a
combination of backslash() followed by a character.
5. These characters combination are called as Escape
sequence.
1/12/2021 MR.RAVVINDRA SALUNKE
Escape
sequence
Represents ASCII Value
0 Null 00
a Alarm (Beep Bell) 07
b Back space 08
t Horizontal tab 09
n New line 10
v Vertical tab 11
f Form feed 12
r Carriage return 13
” Double quote 34
Escape
sequence
Represents ASCII Value
’ Single quote 39
? Question mark 63
 Black slash 92
1/12/2021 MR.RAVVINDRA SALUNKE
Keywords
•32 keywords
•If, else, int,
float….
Identifiers
•Name of
Variables,
Functions,
Arrays
•int num;
Constants
•Integer
Constants
•Character
Constants
Strings
•Array of
characters
•Ended with
‘0’
Special
Symbols
•Brackets
•Parenthesis
•Other
Operators
•Arithmetic
•Assignment
•Logical
•Bitwise
•Conditional
•Increment
Decrement
•Special
Tokens are the smallest elements of a program, which are meaningful to the
compiler.
1/12/2021 MR.RAVVINDRA SALUNKE
 A keyword is a reserved predefined word.
 It cannot use it as a variable name, constant name etc.
 All characters are write in lowercase always
 There are 32 reserved keywords in c language.
auto break case char
const continue default do
double else enum extern
float for goto if
int long register return
short signed sizeof static
struct switch typedef union
unsigned void volatile while
1/12/2021 MR.RAVINDRA SALUNKE
Identifier is a name to identify variable, function, structure, other
user defined object
Rules for constructing C identifiers
1. Identifier must be unique.
2. Keywords cannot be represented as an identifier.
3. Identifier is composed of letters such as uppercase, lowercase
letters, underscore, digits, but the starting letter should be
either an alphabet or an underscore.
4. It should not begin with any numerical digit.
5. identifiers are case sensitive.
6. Commas or blank spaces cannot be specified within an
identifier.
7. The length of the identifiers should not be more than 31
characters.
8. Identifiers should be written in such a way that it is meaningful,
short, and easy to read.
Keyword Identifier
Keyword is a pre-defined reserved
word.
The identifier is a user-defined
word
It must be written in a lowercase
letter.
It can be written in both lowercase
and uppercase letters.
Its meaning is pre-defined in the c
compiler.
Its meaning is not defined in the c
compiler.
It is a combination of alphabetical
characters.
It is a combination of
alphanumeric characters.
It does not contain the underscore
character.
It can contain the underscore
character.
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE
Data Types
Primary
Int Float Char Void
User
Define
Enum Typedef Structure
Derived
Array Pointer
1/12/2021 MR.RAVVINDRA SALUNKE
1. A variable is nothing but a name given to a storage area
2. Each variable in C has a specific type, which determines the size and layout of the
variable's memory and value.
3. The name of a variable can be composed of letters, digits, and the underscore character
4. It must begin with either a letter or an underscore
5. Upper and lowercase letters are distinct because C is case-sensitive
char
Typically a single octet(one byte). It is an integer type.
int
The most natural size of integer for the machine.
float
A single-precision floating point value.
double
A double-precision floating point value.
void
Represents the absence of type.
int i, j, k;
char c, ch;
float f, salary;
double d;
1/12/2021 MR.RAVVINDRA SALUNKE
1. Constants refer to fixed values that the program may not alter
during its execution. These fixed values are also called literals.
2. Constants can be of any of the basic data types like an integer
constant, a floating constant, a character constant, or a string
literal.
3. Constants are treated just like regular variables except that their
values cannot be modified after their definition.
Defining Constants
There are two simple ways in C to define
constants −
Using #define preprocessor.
Using const keyword.
#define LENGTH 10
const int LENGTH = 10;
1/12/2021 MR.RAVVINDRA SALUNKE
An operator is a symbol that tells the compiler to
perform specific mathematical or logical functions.
Types of operators −
1.Arithmetic Operators
2.Relational Operators
3.Logical Operators
4.Bitwise Operators
5.Assignment Operators
6.Misc Operators
1/12/2021 MR.RAVVINDRA SALUNKE
Arithmetic Operators
The following table shows all the arithmetic operators supported by
the C language. Assume variable A holds 10 and variable B holds 20
then −
Operator Description Example
+ Adds two operands. A + B = 30
− Subtracts second operand from the first. A − B = -10
* Multiplies both operands. A * B = 200
/ Divides numerator by de-numerator. B / A = 2
% Modulus Operator and remainder of after an integer division. B % A = 0
++ Increment operator increases the integer value by one. A++ = 11
-- Decrement operator decreases the integer value by one. A-- = 9
1/12/2021 MR.RAVVINDRA SALUNKE
Relational Operators
The following table shows all the relational operators supported by C.
Assume variable A holds 10 and variable B holds 20 then −
Opera
tor
Description Example
== Checks if the values of two operands are equal or not. If yes, then the condition
becomes true.
(A == B) is
not true.
!= Checks if the values of two operands are equal or not. If the values are not equal,
then the condition becomes true.
(A != B) is
true.
> Checks if the value of left operand is greater than the value of right operand. If yes,
then the condition becomes true.
(A > B) is not
true.
< Checks if the value of left operand is less than the value of right operand. If yes, then
the condition becomes true.
(A < B) is
true.
>= Checks if the value of left operand is greater than or equal to the value of right
operand. If yes, then the condition becomes true.
(A >= B) is
not true.
<= Checks if the value of left operand is less than or equal to the value of right operand.
If yes, then the condition becomes true.
(A <= B) is
true.
1/12/2021 MR.RAVVINDRA SALUNKE
Logical Operators
Following table shows all the logical operators supported by C
language. Assume variable A holds 1 and variable B holds 0, then −
Operat
or
Description Example
&& Called Logical AND operator. If both the operands are
non-zero, then the condition becomes true.
(A && B) is false.
|| Called Logical OR Operator. If any of the two operands is
non-zero, then the condition becomes true.
(A || B) is true.
! Called Logical NOT Operator. It is used to reverse the
logical state of its operand. If a condition is true, then
Logical NOT operator will make it false.
!(A && B) is true.
1/12/2021 MR.RAVVINDRA SALUNKE
Bitwise Operators
Bitwise operator works on bits and perform bit-by-bit operation. The
truth tables for &, |, and ^ is as follows −
p q p & q p | q p ^ q
0 0 0 0 0
0 1 0 1 1
1 1 1 1 0
1 0 0 1 1
Assume A = 60 and B = 13 in binary format,
they will be as follows −
A = 0011 1100
B = 0000 1101
-----------------
A&B = 0000 1100
A|B = 0011 1101
A^B = 0011 0001
~A = 1100 0011
256 128 64 32 16 8 4 2 1
A- 1 1 1 1 0 0
B- 1 1 0 1
1/12/2021 MR.RAVVINDRA SALUNKE
Bitwise Operators
Operato
r
Description Example
& Binary AND Operator copies a bit to the result if
it exists in both operands.
(A & B) = 12, i.e., 0000 1100
| Binary OR Operator copies a bit if it exists in
either operand.
(A | B) = 61, i.e., 0011 1101
^ Binary XOR Operator copies the bit if it is set in
one operand but not both.
(A ^ B) = 49, i.e., 0011 0001
~ Binary One's Complement Operator is unary and
has the effect of 'flipping' bits.
(~A ) = ~(60), i.e,. -0111101
<< Binary Left Shift Operator. The left operands
value is moved left by the number of bits
specified by the right operand.
A << 2 = 240 i.e., 1111 0000
>> Binary Right Shift Operator. The left operands
value is moved right by the number of bits
specified by the right operand.
A >> 2 = 15 i.e., 0000 1111
1/12/2021 MR.RAVVINDRA SALUNKE
Assignment Operators
The following table lists the assignment operators supported by the C language −
Operator Description Example
= Simple assignment operator. Assigns values from right side
operands to left side operand
C = A + B will assign the value of A + B to C
+= Add AND assignment operator. It adds the right operand to
the left operand and assign the result to the left operand.
C += A is equivalent to C = C + A
-= Subtract AND assignment operator. It subtracts the right
operand from the left operand and assigns the result to the
left operand.
C -= A is equivalent to C = C - A
*= Multiply AND assignment operator. It multiplies the right
operand with the left operand and assigns the result to the
left operand.
C *= A is equivalent to C = C * A
/= Divide AND assignment operator. It divides the left operand
with the right operand and assigns the result to the left
operand.
C /= A is equivalent to C = C / A
%= Modulus AND assignment operator. It takes modulus using
two operands and assigns the result to the left operand.
C %= A is equivalent to C = C % A
<<= Left shift AND assignment operator. C <<= 2 is same as C = C << 2
>>= Right shift AND assignment operator. C >>= 2 is same as C = C >> 2
&= Bitwise AND assignment operator. C &= 2 is same as C = C & 2
^= Bitwise exclusive OR and assignment operator. C ^= 2 is same as C = C ^ 2
|= Bitwise inclusive OR and assignment operator. C |= 2 is same as C = C | 2
1/12/2021 MR.RAVVINDRA SALUNKE
Misc Operators
Besides the operators discussed above, there are a few other important operators
including sizeof and ? : supported by the C Language.
Operat
or
Description Example
sizeof() Returns the size of a variable. sizeof(a), where a is integer, will return 4.
&
Returns the address of a variable.
&a; returns the actual address of the
variable.
* Pointer to a variable. *a;
? :
Conditional Expression.
If Condition is true ? then value X : otherwise
value Y
1/12/2021 MR.RAVVINDRA SALUNKE
Operators Precedence in C
Operator precedence determines the grouping of terms in an expression and
decides how an expression is evaluated. Certain operators have higher precedence than
others; for example, the multiplication operator has a higher precedence than the addition
operator.
For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has a
higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7.
Here, operators with the highest precedence appear at the top of the table, those
with the lowest appear at the bottom. Within an expression, higher precedence operators
will be evaluated first.
Category Operator Associativity
Postfix () [] -> . ++ - - Left to right
Unary + - ! ~ ++ - - (type)*
& sizeof
Right to left
Multiplicative * / % Left to right
Additive + - Left to right
1/12/2021 MR.RAVVINDRA SALUNKE
Category Operator Associativity
Shift << >> Left to right
Relational < <= > >= Left to right
Equality == != Left to right
Bitwise AND & Left to right
Bitwise XOR ^ Left to right
Bitwise OR | Left to right
Logical AND && Left to right
Logical OR || Left to right
Conditional ?: Right to left
Assignment = += -= *= /= %=>>=
<<= &= ^= |=
Right to left
Comma , Left to right
1/12/2021 MR.RAVVINDRA SALUNKE
1/12/2021 MR.RAVVINDRA SALUNKE

More Related Content

What's hot

Basic C Programming language
Basic C Programming languageBasic C Programming language
Basic C Programming language
Abhishek Soni
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
sachindane
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
Anil Dutt
 
Unit ii
Unit   iiUnit   ii
Unit ii
sathisaran
 
OpenGurukul : Language : C Programming
OpenGurukul : Language : C ProgrammingOpenGurukul : Language : C Programming
OpenGurukul : Language : C Programming
Open Gurukul
 
C Programming basics
C Programming basicsC Programming basics
C Programming basics
Jitin Pillai
 
C language basics
C language basicsC language basics
C language basics
Nikshithas R
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
Wingston
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
javaTpoint s
 
C Programming
C ProgrammingC Programming
C Programming
Adil Jafri
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
Bharat Kalia
 
Unit ii ppt
Unit ii pptUnit ii ppt
C language
C languageC language
C language
Mohamed Bedair
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
Dushmanta Nath
 
C programming language
C programming languageC programming language
C programming language
Mahmoud Eladawi
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
Vivek chan
 
Programming in C- Introduction
Programming in C- IntroductionProgramming in C- Introduction
Programming in C- Introduction
savitamhaske
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
Way2itech
 
Intro to C++ - language
Intro to C++ - languageIntro to C++ - language
Intro to C++ - language
Jussi Pohjolainen
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 

What's hot (20)

Basic C Programming language
Basic C Programming languageBasic C Programming language
Basic C Programming language
 
C Language (All Concept)
C Language (All Concept)C Language (All Concept)
C Language (All Concept)
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
 
Unit ii
Unit   iiUnit   ii
Unit ii
 
OpenGurukul : Language : C Programming
OpenGurukul : Language : C ProgrammingOpenGurukul : Language : C Programming
OpenGurukul : Language : C Programming
 
C Programming basics
C Programming basicsC Programming basics
C Programming basics
 
C language basics
C language basicsC language basics
C language basics
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
C Programming
C ProgrammingC Programming
C Programming
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
C language
C languageC language
C language
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
C programming language
C programming languageC programming language
C programming language
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
Programming in C- Introduction
Programming in C- IntroductionProgramming in C- Introduction
Programming in C- Introduction
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
Intro to C++ - language
Intro to C++ - languageIntro to C++ - language
Intro to C++ - language
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 

Similar to Introduction to c language

The Dynamic Language is not Enough
The Dynamic Language is not EnoughThe Dynamic Language is not Enough
The Dynamic Language is not Enough
Lukas Renggli
 
SL-2.pptx
SL-2.pptxSL-2.pptx
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
SURBHI SAROHA
 
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdfguia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
SilvanildoManoeldaSi
 
1 Revision Tour
1 Revision Tour1 Revision Tour
1 Revision Tour
Praveen M Jigajinni
 
6276830.ppt
6276830.ppt6276830.ppt
6276830.ppt
Shrinivas54
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
Praveen M Jigajinni
 
CS121Lec04.pdf
CS121Lec04.pdfCS121Lec04.pdf
CS121Lec04.pdf
georgejustymirobi1
 
Relational Model
Relational ModelRelational Model
Relational Model
Siti Ismail
 
Presentation 2
Presentation 2Presentation 2
dinoC_ppt.pptx
dinoC_ppt.pptxdinoC_ppt.pptx
dinoC_ppt.pptx
DinobandhuThokdarCST
 
Compilers Design
Compilers DesignCompilers Design
Compilers Design
Akshaya Arunan
 
Programming in c
Programming in cProgramming in c
Programming in c
vineet4523
 
C PADHLO FRANDS.pdf
C PADHLO FRANDS.pdfC PADHLO FRANDS.pdf
C PADHLO FRANDS.pdf
RishiBhardwaj65
 
U2.ppt
U2.pptU2.ppt
U2.ppt
thenmozhip8
 
U2.ppt
U2.pptU2.ppt
Relational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptRelational Algebra and Calculus.ppt
Relational Algebra and Calculus.ppt
Ankush138
 
Features and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for BeginnersFeatures and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for Beginners
Chandrakant Divate
 
Basics of c
Basics of cBasics of c
Basics of c
DebanjanSarkar11
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
SINGH PROJECTS
 

Similar to Introduction to c language (20)

The Dynamic Language is not Enough
The Dynamic Language is not EnoughThe Dynamic Language is not Enough
The Dynamic Language is not Enough
 
SL-2.pptx
SL-2.pptxSL-2.pptx
SL-2.pptx
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdfguia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
 
1 Revision Tour
1 Revision Tour1 Revision Tour
1 Revision Tour
 
6276830.ppt
6276830.ppt6276830.ppt
6276830.ppt
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
CS121Lec04.pdf
CS121Lec04.pdfCS121Lec04.pdf
CS121Lec04.pdf
 
Relational Model
Relational ModelRelational Model
Relational Model
 
Presentation 2
Presentation 2Presentation 2
Presentation 2
 
dinoC_ppt.pptx
dinoC_ppt.pptxdinoC_ppt.pptx
dinoC_ppt.pptx
 
Compilers Design
Compilers DesignCompilers Design
Compilers Design
 
Programming in c
Programming in cProgramming in c
Programming in c
 
C PADHLO FRANDS.pdf
C PADHLO FRANDS.pdfC PADHLO FRANDS.pdf
C PADHLO FRANDS.pdf
 
U2.ppt
U2.pptU2.ppt
U2.ppt
 
U2.ppt
U2.pptU2.ppt
U2.ppt
 
Relational Algebra and Calculus.ppt
Relational Algebra and Calculus.pptRelational Algebra and Calculus.ppt
Relational Algebra and Calculus.ppt
 
Features and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for BeginnersFeatures and Fundamentals of C Language for Beginners
Features and Fundamentals of C Language for Beginners
 
Basics of c
Basics of cBasics of c
Basics of c
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
 

Recently uploaded

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 

Recently uploaded (20)

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 

Introduction to c language

  • 1. C - Programming Unit 1 Introduction to ‘C’ Language
  • 2. 1/12/2021 MR.RAVVINDRA SALUNKE 1.1 History 1.2 Basic Structure of ‘C’ Program 1.3 Language Fundamentals 1.3.1 Character Set, Tokens 1.3.2 Keywords and Identifiers 1.3.3 Variables and Data Types 1.4 Operators 1.4.1 Types of operators 1.4.2 Precedence and associativity 1.4.3 Expression
  • 3. 1/12/2021 MR.RAVVINDRA SALUNKE  Developed in 1972 by Dennis Ritchie at AT&T (American Telephone & Telegraph) bell laboratories, U.S.A.
  • 25. Assignment No 1 (Date- 08 Dec. 2020) Q. 1. Write a short note on History of C Language Q. 2. Write full form of following a. BCPL b. ANSIc. ISO Q. 3. Write a c program to display Hello World. Q. 4. Write a c program to display addition of two numbers Note: 1. Write this assignment in C Programing notebook 2. Take a sequential photos of your assignment & create pdf file and send it on email bbaca2020.21@gmail.com 3. Last date of submission 10 Dec. 2020 1/12/2021 MR.RAVVINDRA SALUNKE
  • 26. 1/12/2021 MR.RAVVINDRA SALUNKE - Character set - Tokens - Keywords and identifiers - Variables and data types
  • 27. 1/12/2021 MR.RAVVINDRA SALUNKE Character Set Source Character Set Capital Alphabets Small Alphabets 0-9 Digits Special Symbols White Space Character Execution Character Set Backslash or Escape Sequence Character A-Z a-z 0-9 30 Symbol 11
  • 28. 1/12/2021 MR.RAVVINDRA SALUNKE Alphabets ASSCI Value A 65 B 66 C 67 D 68 E 69 F 70 G 71 H 72 I 73 Alphabets ASSCI Value J 74 K 75 L 76 M 77 N 78 O 79 P 80 Q 81 R 82 Alphabets ASSCI Value S 83 T 84 U 85 V 86 W 87 X 88 Y 89 Z 90 Capital Alphabets- A-Z
  • 29. 1/12/2021 MR.RAVVINDRA SALUNKE Alphabets ASSCI Value a 97 b 98 c 99 d 100 e 101 f 102 g 103 h 104 i 105 Alphabets ASSCI Value j 106 k 107 l 108 m 109 n 110 o 111 p 112 q 113 r 114 Alphabets ASSCI Value s 115 t 116 u 117 v 118 w 119 x 120 y 121 z 122 Small Alphabets- a-z
  • 30. 1/12/2021 MR.RAVVINDRA SALUNKE Alphabets ASSCI Value 0 48 1 49 2 50 3 51 4 52 5 53 Alphabets ASSCI Value 6 54 7 55 8 56 9 57 Digits 0-9
  • 31. 1/12/2021 MR.RAVVINDRA SALUNKE Alphab ets ASSCI Value Represents ! 32 Exclamation mark “ 34 Quotation mark # 35 Number sign $ 36 Dollar Sign % 37 Percent sign $ 38 Ampersand Alpha bets ASSCI Value Represents ( 40 Left parenthesis ) 41 Right parenthesis * 42 Asterisk + 43 Plus sign Special Characters -
  • 32. 1/12/2021 MR.RAVVINDRA SALUNKE Alphab ets ASSCI Value Represents ‘ 44 Comma - 45 Minus sign . 46 Period / 47 Slash : 58 Colon ; 59 Semicolon < 60 less then sign = 61 Equal sign > 62 Greater than sign Alpha bets ASSCI Value Represents ? 63 Question mark @ 64 at symbol [ 91 Left bracket 92 Black slash ] 93 Right bracket ^ 94 Caret _ 95 Under score { 123 Left brace | 124 Vertical bar
  • 34. 1/12/2021 MR.RAVVINDRA SALUNKE Constant Represents b Blank space Back slash n New line f Form feed 0 Null v Vertical tab t Horizontal tab ’ Single quote r Carriage return Constant Represents a Alarm(bell) ? Question mark
  • 35. 1/12/2021 MR.RAVVINDRA SALUNKE 1. Certain ASCII character are unprintable which means they are not displayed on the screen or printer. 2. Those character performed other function aside from displaying text. 3. Examples are - backspacing , moving to a newline or , ringing a bell this are used in output statements. 4. Execution character set are always represented by a combination of backslash() followed by a character. 5. These characters combination are called as Escape sequence.
  • 36. 1/12/2021 MR.RAVVINDRA SALUNKE Escape sequence Represents ASCII Value 0 Null 00 a Alarm (Beep Bell) 07 b Back space 08 t Horizontal tab 09 n New line 10 v Vertical tab 11 f Form feed 12 r Carriage return 13 ” Double quote 34 Escape sequence Represents ASCII Value ’ Single quote 39 ? Question mark 63 Black slash 92
  • 37. 1/12/2021 MR.RAVVINDRA SALUNKE Keywords •32 keywords •If, else, int, float…. Identifiers •Name of Variables, Functions, Arrays •int num; Constants •Integer Constants •Character Constants Strings •Array of characters •Ended with ‘0’ Special Symbols •Brackets •Parenthesis •Other Operators •Arithmetic •Assignment •Logical •Bitwise •Conditional •Increment Decrement •Special Tokens are the smallest elements of a program, which are meaningful to the compiler.
  • 38. 1/12/2021 MR.RAVVINDRA SALUNKE  A keyword is a reserved predefined word.  It cannot use it as a variable name, constant name etc.  All characters are write in lowercase always  There are 32 reserved keywords in c language. auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while
  • 39. 1/12/2021 MR.RAVINDRA SALUNKE Identifier is a name to identify variable, function, structure, other user defined object Rules for constructing C identifiers 1. Identifier must be unique. 2. Keywords cannot be represented as an identifier. 3. Identifier is composed of letters such as uppercase, lowercase letters, underscore, digits, but the starting letter should be either an alphabet or an underscore. 4. It should not begin with any numerical digit. 5. identifiers are case sensitive. 6. Commas or blank spaces cannot be specified within an identifier. 7. The length of the identifiers should not be more than 31 characters. 8. Identifiers should be written in such a way that it is meaningful, short, and easy to read.
  • 40. Keyword Identifier Keyword is a pre-defined reserved word. The identifier is a user-defined word It must be written in a lowercase letter. It can be written in both lowercase and uppercase letters. Its meaning is pre-defined in the c compiler. Its meaning is not defined in the c compiler. It is a combination of alphabetical characters. It is a combination of alphanumeric characters. It does not contain the underscore character. It can contain the underscore character. 1/12/2021 MR.RAVVINDRA SALUNKE
  • 41. 1/12/2021 MR.RAVVINDRA SALUNKE Data Types Primary Int Float Char Void User Define Enum Typedef Structure Derived Array Pointer
  • 42. 1/12/2021 MR.RAVVINDRA SALUNKE 1. A variable is nothing but a name given to a storage area 2. Each variable in C has a specific type, which determines the size and layout of the variable's memory and value. 3. The name of a variable can be composed of letters, digits, and the underscore character 4. It must begin with either a letter or an underscore 5. Upper and lowercase letters are distinct because C is case-sensitive char Typically a single octet(one byte). It is an integer type. int The most natural size of integer for the machine. float A single-precision floating point value. double A double-precision floating point value. void Represents the absence of type. int i, j, k; char c, ch; float f, salary; double d;
  • 43. 1/12/2021 MR.RAVVINDRA SALUNKE 1. Constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. 2. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. 3. Constants are treated just like regular variables except that their values cannot be modified after their definition. Defining Constants There are two simple ways in C to define constants − Using #define preprocessor. Using const keyword. #define LENGTH 10 const int LENGTH = 10;
  • 44. 1/12/2021 MR.RAVVINDRA SALUNKE An operator is a symbol that tells the compiler to perform specific mathematical or logical functions. Types of operators − 1.Arithmetic Operators 2.Relational Operators 3.Logical Operators 4.Bitwise Operators 5.Assignment Operators 6.Misc Operators
  • 45. 1/12/2021 MR.RAVVINDRA SALUNKE Arithmetic Operators The following table shows all the arithmetic operators supported by the C language. Assume variable A holds 10 and variable B holds 20 then − Operator Description Example + Adds two operands. A + B = 30 − Subtracts second operand from the first. A − B = -10 * Multiplies both operands. A * B = 200 / Divides numerator by de-numerator. B / A = 2 % Modulus Operator and remainder of after an integer division. B % A = 0 ++ Increment operator increases the integer value by one. A++ = 11 -- Decrement operator decreases the integer value by one. A-- = 9
  • 46. 1/12/2021 MR.RAVVINDRA SALUNKE Relational Operators The following table shows all the relational operators supported by C. Assume variable A holds 10 and variable B holds 20 then − Opera tor Description Example == Checks if the values of two operands are equal or not. If yes, then the condition becomes true. (A == B) is not true. != Checks if the values of two operands are equal or not. If the values are not equal, then the condition becomes true. (A != B) is true. > Checks if the value of left operand is greater than the value of right operand. If yes, then the condition becomes true. (A > B) is not true. < Checks if the value of left operand is less than the value of right operand. If yes, then the condition becomes true. (A < B) is true. >= Checks if the value of left operand is greater than or equal to the value of right operand. If yes, then the condition becomes true. (A >= B) is not true. <= Checks if the value of left operand is less than or equal to the value of right operand. If yes, then the condition becomes true. (A <= B) is true.
  • 47. 1/12/2021 MR.RAVVINDRA SALUNKE Logical Operators Following table shows all the logical operators supported by C language. Assume variable A holds 1 and variable B holds 0, then − Operat or Description Example && Called Logical AND operator. If both the operands are non-zero, then the condition becomes true. (A && B) is false. || Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true. (A || B) is true. ! Called Logical NOT Operator. It is used to reverse the logical state of its operand. If a condition is true, then Logical NOT operator will make it false. !(A && B) is true.
  • 48. 1/12/2021 MR.RAVVINDRA SALUNKE Bitwise Operators Bitwise operator works on bits and perform bit-by-bit operation. The truth tables for &, |, and ^ is as follows − p q p & q p | q p ^ q 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 1 0 0 1 1 Assume A = 60 and B = 13 in binary format, they will be as follows − A = 0011 1100 B = 0000 1101 ----------------- A&B = 0000 1100 A|B = 0011 1101 A^B = 0011 0001 ~A = 1100 0011 256 128 64 32 16 8 4 2 1 A- 1 1 1 1 0 0 B- 1 1 0 1
  • 49. 1/12/2021 MR.RAVVINDRA SALUNKE Bitwise Operators Operato r Description Example & Binary AND Operator copies a bit to the result if it exists in both operands. (A & B) = 12, i.e., 0000 1100 | Binary OR Operator copies a bit if it exists in either operand. (A | B) = 61, i.e., 0011 1101 ^ Binary XOR Operator copies the bit if it is set in one operand but not both. (A ^ B) = 49, i.e., 0011 0001 ~ Binary One's Complement Operator is unary and has the effect of 'flipping' bits. (~A ) = ~(60), i.e,. -0111101 << Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. A << 2 = 240 i.e., 1111 0000 >> Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. A >> 2 = 15 i.e., 0000 1111
  • 50. 1/12/2021 MR.RAVVINDRA SALUNKE Assignment Operators The following table lists the assignment operators supported by the C language − Operator Description Example = Simple assignment operator. Assigns values from right side operands to left side operand C = A + B will assign the value of A + B to C += Add AND assignment operator. It adds the right operand to the left operand and assign the result to the left operand. C += A is equivalent to C = C + A -= Subtract AND assignment operator. It subtracts the right operand from the left operand and assigns the result to the left operand. C -= A is equivalent to C = C - A *= Multiply AND assignment operator. It multiplies the right operand with the left operand and assigns the result to the left operand. C *= A is equivalent to C = C * A /= Divide AND assignment operator. It divides the left operand with the right operand and assigns the result to the left operand. C /= A is equivalent to C = C / A %= Modulus AND assignment operator. It takes modulus using two operands and assigns the result to the left operand. C %= A is equivalent to C = C % A <<= Left shift AND assignment operator. C <<= 2 is same as C = C << 2 >>= Right shift AND assignment operator. C >>= 2 is same as C = C >> 2 &= Bitwise AND assignment operator. C &= 2 is same as C = C & 2 ^= Bitwise exclusive OR and assignment operator. C ^= 2 is same as C = C ^ 2 |= Bitwise inclusive OR and assignment operator. C |= 2 is same as C = C | 2
  • 51. 1/12/2021 MR.RAVVINDRA SALUNKE Misc Operators Besides the operators discussed above, there are a few other important operators including sizeof and ? : supported by the C Language. Operat or Description Example sizeof() Returns the size of a variable. sizeof(a), where a is integer, will return 4. & Returns the address of a variable. &a; returns the actual address of the variable. * Pointer to a variable. *a; ? : Conditional Expression. If Condition is true ? then value X : otherwise value Y
  • 52. 1/12/2021 MR.RAVVINDRA SALUNKE Operators Precedence in C Operator precedence determines the grouping of terms in an expression and decides how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has a higher precedence than the addition operator. For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has a higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7. Here, operators with the highest precedence appear at the top of the table, those with the lowest appear at the bottom. Within an expression, higher precedence operators will be evaluated first. Category Operator Associativity Postfix () [] -> . ++ - - Left to right Unary + - ! ~ ++ - - (type)* & sizeof Right to left Multiplicative * / % Left to right Additive + - Left to right
  • 53. 1/12/2021 MR.RAVVINDRA SALUNKE Category Operator Associativity Shift << >> Left to right Relational < <= > >= Left to right Equality == != Left to right Bitwise AND & Left to right Bitwise XOR ^ Left to right Bitwise OR | Left to right Logical AND && Left to right Logical OR || Left to right Conditional ?: Right to left Assignment = += -= *= /= %=>>= <<= &= ^= |= Right to left Comma , Left to right