SlideShare a Scribd company logo
Operators in ‘C’
In C language, operators are categorized in following six categories :
 Arithmetic: Perform basic mathematical operations over one or more than one operands.
 Relational and Logical operator: Relational operators are used to compare two
expressions and return the value as 0 and 1. Logical operator combines two or more
operands.
 Bitwise: Bitwise operator operates at bit level..
 Assignment Operator: Assigns value.
Technical Training (C Basics)
Operators in ‘C’
Simplest meaning of operator is which works on operand.
 Arithmetic:
 Perform basic mathematical operations on operands.
1-Unary Operator (one operand)
2-Binary Operator (two operand)
Unary Operator (one operand)
Increment- The ++ operator is used to increment the value of integer.
a++ post increment ++a pre increment
Decrement- The -- operator is used to decrement the value of integer.
a-- post decrement --a pre decrement
Technical Training (C Basics)
Operator Definition Example Unary or Binary
+ adds two operands a+b binary
- Subtracts second operands from first. a-b binary
* multiply two operands a*b binary
/ Divides numerator by denominator. a/b binary
% Gives remainder after an integer division. a%b binary
++ Increase an integer value by one. ++a , a++ unary
-- Decrease an integer value by one. --a , a-- unary
Technical Training (C Basics)
What would be the output of the above code ? Choose
the correct option.
A. 1.0 B. 5.0
C. 2.0 D. Error
Technical Training (C Basics)
#include <stdio.h>
int main(void)
{
float a=5.0,b=2.0,c;
c=a % b;
printf("%f",c);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 1.0 B. 5.0
C. 2.0 D. Error
Technical Training (C Basics)
#include <stdio.h>
int main(void)
{
float a=5.0,b=2.0,c;
c=a % b;
printf("%f",c);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 22 B. 32
C. 24 D. 30
Technical Training (C Basics)
#include <stdio.h>
int main(void)
{
int a=5,b=2,c;
c=a++ + ++b + b++ + ++a + a++ + ++b;
printf("%d",c);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 22 B. 32
C. 24 D. 30
Technical Training (C Basics)
#include <stdio.h>
int main(void)
{
int a=5,b=2,c;
c=a++ + ++b + b++ + ++a + a++ + ++b;
printf("%d",c);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 22 B. 12
C. 24 D. Compiler
dependent
Technical Training (C Basics)
#include <stdio.h>
int main(void)
{
int a=5,b=3,c;
c=a-- + --a + b-- + --b + --b + --a;
printf("%d",c);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 22 B. 12
C. 24 D. Compiler
dependent
Technical Training (C Basics)
#include <stdio.h>
int main(void)
{
int a=5,b=3,c;
c=a-- + --a + b-- + --b + --b + --a;
printf("%d",c);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 7 7 6 B. 5 7 8
C. 5 6 7 D. Compiler
dependent
Technical Training (C Basics)
#include <stdio.h>
int main(void)
{
int a=5;
printf("%d%d%d",a++,++a,++a);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 7 7 6 B. 5 7 8
C. 5 6 7 D. Compiler
dependent
Technical Training (C Basics)
#include <stdio.h>
int main(void)
{
int a=5;
printf("%d%d%d",a++,++a,++a);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 4 B. error
C. 5 D. Compiler
dependent
Technical Training (C Basics)
#include <stdio.h>
int main()
{
int i = 3;
printf("%d", (++i)++);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 4 B. error
C. 5 D. Compiler
dependent
Technical Training (C Basics)
#include <stdio.h>
int main()
{
int a = 4;
printf("%d", (++a)++);
return 0;
}
 Bitwise Operator: In C bitwise operator works at bit level.
Operator Definition
& Bitwise And
| Bitwise Or
^ Bitwise XOR
~ Bitwise NOT
>> Right Shift Operator
<< Left Shift Operator
Technical Training (C Basics)
 Bitwise Operator:
points to remember-
1.Left and right shift operators should not be used for negative numbers.
2.if the number is shifted more than the size of integer the behavior is undefined.
3.The bitwise operator should not be used in place of logical operators.
Technical Training (C Basics)
What would be the output of the above code ? Choose
the correct option.
A. 4 B. error
C. 5 D. Compiler
dependent
Technical Training (C Basics)
#include <stdio.h>
int main()
{
int i = 3;
printf("%d", (++i)++);
return 0;
}
Operators in ‘C’
In C language, operators are categorized in following six categories :
 Logical Operator: Perform basic mathematical operations over one or more than one
operands.
Operator Definition
&& Logical And
|| Logical Or
Technical Training (C Basics)
Operators in ‘C’
In C language, operators are categorized in following six categories :
 Assignment Operator:
 It is a binary Operator
 Evaluates the operator on Right side and assigns it to on Left side.
 Example
Technical Training (C Basics)
Operators in ‘C’
In C language, operators are categorized in following six categories :
Operators Type Associativity
() [] -> . Left to right
! ~ ++ -- + - * & (type) sizeof Unary Right to left
* / % Binary Left to right
+ - Binary Left to right
<< >> Binary Left to right
< <= > >= Binary Left to right
== != Binary Left to right
& Binary Left to right
^ Binary Left to right
| Binary Left to right
&& Binary Left to right
|| Binary Left to right
?: Binary Right to left
= += -= *= /= %= &= |= ^= >>= <== Binary Right to left
, Binary Left to right
Technical Training (C Basics)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
int a = 2;
int a;
int main(void) {
printf("%d", a);
int a;
for(int i = 0 ; i < 3 ; i++ )
{
printf("%d", a);
a++;
}
printf("%d", a);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 2 0 1 2 3 B. 2 2 2 2 3
C. 2 1 1 2 2 D. Compiler error
Technical Training (C Basics) TCS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
int a = 2;
int a;
int main(void) {
printf("%d", a);
int a;
for(int i = 0 ; i < 3 ; i++ )
{
printf("%d", a);
a++;
}
printf("%d", a);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 2 0 1 2 3 B. 2 2 2 2 3
C. 2 1 1 2 2 D. Compiler error
Technical Training (C Basics) TCS
1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
int a = 12;
int main(void) {
for(int j = 0; j <= 1; j++)
{
int a = 4;
a++;
}
printf("%d" , a);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 4 B. 12
C. 5 D. Compiler error
Technical Training (C Basics) Capegemini
1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
int a = 12;
int main(void) {
for(int j = 0; j <= 1; j++)
{
int a = 4;
a++;
}
printf("%d" , a);
return 0;
}
What would be the output of the above code ? Choose
the correct option.
A. 4 B. 12
C. 5 D. Compiler error
Technical Training (C Basics) Capegemini
1
2
3
4
5
6
7
8
9
10
What would be the output of the above code ? Choose
the correct option.
A. 4 B. 5
C. 6 D. Error
#include <stdio.h>
int main(void) {
for(int i = 0; i < 2; i++)
{
static int a = 4;
a++;
}
printf("%d", a);
return 0;
}
Technical Training (C Basics) TCS
1
2
3
4
5
6
7
8
9
10
What would be the output of the above code ? Choose
the correct option.
A. 4 B. 5
C. 6 D. Error
#include <stdio.h>
int main(void) {
for(int i = 0; i < 2; i++)
{
static int a = 4;
a++;
}
printf("%d", a);
return 0;
}
Technical Training (C Basics) TCS
1
2
3
4
5
6
7
8
9
10
11
12
13
What would be the output of the above code ? Choose
the correct option.
A. 0 1 B. 2 3
C. 3 4 D. Error
#include <stdio.h>
int a;
int main(void) {
{
a = 2;
}
for(int i = 0; i < 2; i++)
{
a++ ;
printf("%d " , a);
}
return 0 ;
}
Technical Training (C Basics) Capegemini
1
2
3
4
5
6
7
8
9
10
11
12
13
What would be the output of the above code ? Choose
the correct option.
A. 0 1 B. 2 3
C. 3 4 D. Error
#include <stdio.h>
int a;
int main(void) {
{
a = 2;
}
for(int i = 0; i < 2; i++)
{
a++ ;
printf("%d " , a);
}
return 0 ;
}
Technical Training (C Basics) Capegemini
1
2
3
4
5
6
7
8
9
10
11
12
What would be the output of the above code ? Choose
the correct option.
A. 1 10 0 B. 1 10 1
C. 1 10 10 D. Error
#include <stdio.h>
int main(void) {
int x = 1 ;
printf("%d", x ); {
int x = 10;
printf("%d", x ); {
x;
printf("%d", x );
}
}
return 0;
}
Technical Training (C Basics) Infosys
1
2
3
4
5
6
7
8
9
10
11
12
What would be the output of the above code ? Choose
the correct option.
A. 1 10 0 B. 1 10 1
C. 1 10 10 D. Error
#include <stdio.h>
int main(void) {
int x = 1 ;
printf("%d", x ); {
int x = 10;
printf("%d", x ); {
x;
printf("%d", x );
}
}
return 0;
}
Technical Training (C Basics) Infosys
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
What would be the output of the above code ? Choose
the correct option.
A. 20 20 B. 30 20
C. 10 20 D. 20 30
# include<stdio.h>
int a = 10;
int main(void) {
{
a = 30;
{
{
a = 20;
printf("%d", a);
}
}
printf("%d", a);
}
return 0;
}
Technical Training (C Basics) Accenture
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
What would be the output of the above code ? Choose
the correct option.
A. 20 20 B. 30 20
C. 10 20 D. 20 30
# include<stdio.h>
int a = 10;
int main(void) {
{
a = 30;
{
{
a = 20;
printf("%d", a);
}
}
printf("%d", a);
}
return 0;
}
Technical Training (C Basics) Accenture
1
2
3
4
5
6
What would be the output of the above code ? Choose
the correct option.
A. 28 B. 25
C. 29 D. 30
#include<stdio.h>
int main(void) {
int a = 7;
int s = a++ + ++a + a-- + a % 2;
printf("%d", s);
}
Technical Training (C Basics) TCS
1
2
3
4
5
6
What would be the output of the above code ? Choose
the correct option.
A. 28 B. 25
C. 29 D. 30
#include<stdio.h>
int main(void) {
int a = 7;
int s = a++ + ++a + a-- + a % 2;
printf("%d", s);
}
Technical Training (C Basics) TCS
1
2
3
4
5
6
7
8
9
What would be the output of the above code ? Choose
the correct option.
A. 2 1 1 B. 3 2 1
C. 3 1 1 D. 2 2 1
#include<stdio.h>
int main(void) {
int i = 1, j = 2, k, l = 1;
{
k = i++ + ++i + j || l++;
printf("%d %d %d", i, l, k);
}
return 0;
}
Technical Training (C Basics) Capegemini
1
2
3
4
5
6
7
8
9
What would be the output of the above code ? Choose
the correct option.
A. 2 1 1 B. 3 2 1
C. 3 1 1 D. 2 2 1
#include<stdio.h>
int main(void) {
int i = 1, j = 2, k, l = 1;
{
k = i++ + ++i + j || l++;
printf("%d %d %d", i, l, k);
}
return 0;
}
Technical Training (C Basics) Capegemini
1
2
3
4
5
6
What would be the output of the above code ? Choose
the correct option.
A. 3 B. 4
C. 2 D. 1
#include <stdio.h>
int main(void) {
int a = 5;
int s = a-- || a-- && 4;
printf("%d", s);
}
Technical Training (C Basics) Infosys
1
2
3
4
5
6
What would be the output of the above code ? Choose
the correct option.
A. 3 B. 4
C. 2 D. 1
#include <stdio.h>
int main(void) {
int a = 5;
int s = a-- || a-- && 4;
printf("%d", s);
}
Technical Training (C Basics) Infosys
1
2
3
4
5
6
7
8
9
What would be the output of the above code ? Choose
the correct option.
A. 1 0 2 B. 1 1 3
C. 2 0 3 D. 2 1 2
#include<stdio.h>
int main(void) {
int i = 0, j = 2, k, l = 0;
{
k = (i++ && l++ ) || j++ + i++;
printf("%d %d %d", i, l, j);
}
return 0;
}
Technical Training (C Basics) Accenture
1
2
3
4
5
6
7
8
9
What would be the output of the above code ? Choose
the correct option.
A. 1 0 2 B. 1 1 3
C. 2 0 3 D. 2 1 2
#include<stdio.h>
int main(void) {
int i = 0, j = 2, k, l = 0;
{
k = (i++ && l++ ) || j++ + i++;
printf("%d %d %d", i, l, j);
}
return 0;
}
Technical Training (C Basics) Accenture
1
2
3
4
5
6
7
8
9
10
What would be the output of the above code ? Choose
the correct option.
A. 4 5 B. 4 4
C. 5 4 D. 5 5
#include<stdio.h>
int main(void) {
int i = 10, j = 10;
int k = 4;
{
printf("%d", sizeof(k /= i+j));
printf("%d", k) ;
}
return 0;
}
Technical Training (C Basics) Infosys
1
2
3
4
5
6
7
8
9
10
What would be the output of the above code ? Choose
the correct option.
A. 4 5 B. 4 4
C. 5 4 D. 5 5
#include<stdio.h>
int main(void) {
int i = 10, j = 10;
int k = 4;
{
printf("%d", sizeof(k /= i+j));
printf("%d", k) ;
}
return 0;
}
Technical Training (C Basics) Infosys

More Related Content

Similar to operators.ppt

Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans incnayakq
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
Saket Pathak
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
YashwanthCse
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
Sujata Regoti
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
Dipta Saha
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
Abhishekkumarsingh630054
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
Zaibi Gondal
 
Technical quiz 5#.pptx
Technical quiz 5#.pptxTechnical quiz 5#.pptx
Technical quiz 5#.pptx
kamalPatelposhala
 
C programming Lab 1
C programming Lab 1C programming Lab 1
C programming Lab 1
Zaibi Gondal
 
Unit i intro-operators
Unit   i intro-operatorsUnit   i intro-operators
Unit i intro-operators
HINAPARVEENAlXC
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
EasyStudy3
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
praveensomesh
 
C language
C languageC language
C language
Priya698357
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
Amrinder Sidhu
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
Nilesh Dalvi
 
Java Quiz
Java QuizJava Quiz
Java Quiz
Dharmraj Sharma
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
Don Dooley
 
Oops Quiz
Oops QuizOops Quiz

Similar to operators.ppt (20)

Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
 
Technical aptitude Test 1 CSE
Technical aptitude Test 1 CSETechnical aptitude Test 1 CSE
Technical aptitude Test 1 CSE
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
C exam
C examC exam
C exam
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
Technical quiz 5#.pptx
Technical quiz 5#.pptxTechnical quiz 5#.pptx
Technical quiz 5#.pptx
 
C programming Lab 1
C programming Lab 1C programming Lab 1
C programming Lab 1
 
Unit i intro-operators
Unit   i intro-operatorsUnit   i intro-operators
Unit i intro-operators
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
 
C language
C languageC language
C language
 
ppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operatorsppt on logical/arthimatical/conditional operators
ppt on logical/arthimatical/conditional operators
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Java Quiz
Java QuizJava Quiz
Java Quiz
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
Oops Quiz
Oops QuizOops Quiz
Oops Quiz
 

Recently uploaded

Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 

Recently uploaded (20)

Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 

operators.ppt

  • 1. Operators in ‘C’ In C language, operators are categorized in following six categories :  Arithmetic: Perform basic mathematical operations over one or more than one operands.  Relational and Logical operator: Relational operators are used to compare two expressions and return the value as 0 and 1. Logical operator combines two or more operands.  Bitwise: Bitwise operator operates at bit level..  Assignment Operator: Assigns value. Technical Training (C Basics)
  • 2. Operators in ‘C’ Simplest meaning of operator is which works on operand.  Arithmetic:  Perform basic mathematical operations on operands. 1-Unary Operator (one operand) 2-Binary Operator (two operand) Unary Operator (one operand) Increment- The ++ operator is used to increment the value of integer. a++ post increment ++a pre increment Decrement- The -- operator is used to decrement the value of integer. a-- post decrement --a pre decrement Technical Training (C Basics)
  • 3. Operator Definition Example Unary or Binary + adds two operands a+b binary - Subtracts second operands from first. a-b binary * multiply two operands a*b binary / Divides numerator by denominator. a/b binary % Gives remainder after an integer division. a%b binary ++ Increase an integer value by one. ++a , a++ unary -- Decrease an integer value by one. --a , a-- unary Technical Training (C Basics)
  • 4. What would be the output of the above code ? Choose the correct option. A. 1.0 B. 5.0 C. 2.0 D. Error Technical Training (C Basics) #include <stdio.h> int main(void) { float a=5.0,b=2.0,c; c=a % b; printf("%f",c); return 0; }
  • 5. What would be the output of the above code ? Choose the correct option. A. 1.0 B. 5.0 C. 2.0 D. Error Technical Training (C Basics) #include <stdio.h> int main(void) { float a=5.0,b=2.0,c; c=a % b; printf("%f",c); return 0; }
  • 6. What would be the output of the above code ? Choose the correct option. A. 22 B. 32 C. 24 D. 30 Technical Training (C Basics) #include <stdio.h> int main(void) { int a=5,b=2,c; c=a++ + ++b + b++ + ++a + a++ + ++b; printf("%d",c); return 0; }
  • 7. What would be the output of the above code ? Choose the correct option. A. 22 B. 32 C. 24 D. 30 Technical Training (C Basics) #include <stdio.h> int main(void) { int a=5,b=2,c; c=a++ + ++b + b++ + ++a + a++ + ++b; printf("%d",c); return 0; }
  • 8. What would be the output of the above code ? Choose the correct option. A. 22 B. 12 C. 24 D. Compiler dependent Technical Training (C Basics) #include <stdio.h> int main(void) { int a=5,b=3,c; c=a-- + --a + b-- + --b + --b + --a; printf("%d",c); return 0; }
  • 9. What would be the output of the above code ? Choose the correct option. A. 22 B. 12 C. 24 D. Compiler dependent Technical Training (C Basics) #include <stdio.h> int main(void) { int a=5,b=3,c; c=a-- + --a + b-- + --b + --b + --a; printf("%d",c); return 0; }
  • 10. What would be the output of the above code ? Choose the correct option. A. 7 7 6 B. 5 7 8 C. 5 6 7 D. Compiler dependent Technical Training (C Basics) #include <stdio.h> int main(void) { int a=5; printf("%d%d%d",a++,++a,++a); return 0; }
  • 11. What would be the output of the above code ? Choose the correct option. A. 7 7 6 B. 5 7 8 C. 5 6 7 D. Compiler dependent Technical Training (C Basics) #include <stdio.h> int main(void) { int a=5; printf("%d%d%d",a++,++a,++a); return 0; }
  • 12. What would be the output of the above code ? Choose the correct option. A. 4 B. error C. 5 D. Compiler dependent Technical Training (C Basics) #include <stdio.h> int main() { int i = 3; printf("%d", (++i)++); return 0; }
  • 13. What would be the output of the above code ? Choose the correct option. A. 4 B. error C. 5 D. Compiler dependent Technical Training (C Basics) #include <stdio.h> int main() { int a = 4; printf("%d", (++a)++); return 0; }
  • 14.  Bitwise Operator: In C bitwise operator works at bit level. Operator Definition & Bitwise And | Bitwise Or ^ Bitwise XOR ~ Bitwise NOT >> Right Shift Operator << Left Shift Operator Technical Training (C Basics)
  • 15.  Bitwise Operator: points to remember- 1.Left and right shift operators should not be used for negative numbers. 2.if the number is shifted more than the size of integer the behavior is undefined. 3.The bitwise operator should not be used in place of logical operators. Technical Training (C Basics)
  • 16. What would be the output of the above code ? Choose the correct option. A. 4 B. error C. 5 D. Compiler dependent Technical Training (C Basics) #include <stdio.h> int main() { int i = 3; printf("%d", (++i)++); return 0; }
  • 17. Operators in ‘C’ In C language, operators are categorized in following six categories :  Logical Operator: Perform basic mathematical operations over one or more than one operands. Operator Definition && Logical And || Logical Or Technical Training (C Basics)
  • 18. Operators in ‘C’ In C language, operators are categorized in following six categories :  Assignment Operator:  It is a binary Operator  Evaluates the operator on Right side and assigns it to on Left side.  Example Technical Training (C Basics)
  • 19. Operators in ‘C’ In C language, operators are categorized in following six categories : Operators Type Associativity () [] -> . Left to right ! ~ ++ -- + - * & (type) sizeof Unary Right to left * / % Binary Left to right + - Binary Left to right << >> Binary Left to right < <= > >= Binary Left to right == != Binary Left to right & Binary Left to right ^ Binary Left to right | Binary Left to right && Binary Left to right || Binary Left to right ?: Binary Right to left = += -= *= /= %= &= |= ^= >>= <== Binary Right to left , Binary Left to right Technical Training (C Basics)
  • 20. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include <stdio.h> int a = 2; int a; int main(void) { printf("%d", a); int a; for(int i = 0 ; i < 3 ; i++ ) { printf("%d", a); a++; } printf("%d", a); return 0; } What would be the output of the above code ? Choose the correct option. A. 2 0 1 2 3 B. 2 2 2 2 3 C. 2 1 1 2 2 D. Compiler error Technical Training (C Basics) TCS
  • 21. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include <stdio.h> int a = 2; int a; int main(void) { printf("%d", a); int a; for(int i = 0 ; i < 3 ; i++ ) { printf("%d", a); a++; } printf("%d", a); return 0; } What would be the output of the above code ? Choose the correct option. A. 2 0 1 2 3 B. 2 2 2 2 3 C. 2 1 1 2 2 D. Compiler error Technical Training (C Basics) TCS
  • 22. 1 2 3 4 5 6 7 8 9 10 11 #include <stdio.h> int a = 12; int main(void) { for(int j = 0; j <= 1; j++) { int a = 4; a++; } printf("%d" , a); return 0; } What would be the output of the above code ? Choose the correct option. A. 4 B. 12 C. 5 D. Compiler error Technical Training (C Basics) Capegemini
  • 23. 1 2 3 4 5 6 7 8 9 10 11 #include <stdio.h> int a = 12; int main(void) { for(int j = 0; j <= 1; j++) { int a = 4; a++; } printf("%d" , a); return 0; } What would be the output of the above code ? Choose the correct option. A. 4 B. 12 C. 5 D. Compiler error Technical Training (C Basics) Capegemini
  • 24. 1 2 3 4 5 6 7 8 9 10 What would be the output of the above code ? Choose the correct option. A. 4 B. 5 C. 6 D. Error #include <stdio.h> int main(void) { for(int i = 0; i < 2; i++) { static int a = 4; a++; } printf("%d", a); return 0; } Technical Training (C Basics) TCS
  • 25. 1 2 3 4 5 6 7 8 9 10 What would be the output of the above code ? Choose the correct option. A. 4 B. 5 C. 6 D. Error #include <stdio.h> int main(void) { for(int i = 0; i < 2; i++) { static int a = 4; a++; } printf("%d", a); return 0; } Technical Training (C Basics) TCS
  • 26. 1 2 3 4 5 6 7 8 9 10 11 12 13 What would be the output of the above code ? Choose the correct option. A. 0 1 B. 2 3 C. 3 4 D. Error #include <stdio.h> int a; int main(void) { { a = 2; } for(int i = 0; i < 2; i++) { a++ ; printf("%d " , a); } return 0 ; } Technical Training (C Basics) Capegemini
  • 27. 1 2 3 4 5 6 7 8 9 10 11 12 13 What would be the output of the above code ? Choose the correct option. A. 0 1 B. 2 3 C. 3 4 D. Error #include <stdio.h> int a; int main(void) { { a = 2; } for(int i = 0; i < 2; i++) { a++ ; printf("%d " , a); } return 0 ; } Technical Training (C Basics) Capegemini
  • 28. 1 2 3 4 5 6 7 8 9 10 11 12 What would be the output of the above code ? Choose the correct option. A. 1 10 0 B. 1 10 1 C. 1 10 10 D. Error #include <stdio.h> int main(void) { int x = 1 ; printf("%d", x ); { int x = 10; printf("%d", x ); { x; printf("%d", x ); } } return 0; } Technical Training (C Basics) Infosys
  • 29. 1 2 3 4 5 6 7 8 9 10 11 12 What would be the output of the above code ? Choose the correct option. A. 1 10 0 B. 1 10 1 C. 1 10 10 D. Error #include <stdio.h> int main(void) { int x = 1 ; printf("%d", x ); { int x = 10; printf("%d", x ); { x; printf("%d", x ); } } return 0; } Technical Training (C Basics) Infosys
  • 30. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 What would be the output of the above code ? Choose the correct option. A. 20 20 B. 30 20 C. 10 20 D. 20 30 # include<stdio.h> int a = 10; int main(void) { { a = 30; { { a = 20; printf("%d", a); } } printf("%d", a); } return 0; } Technical Training (C Basics) Accenture
  • 31. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 What would be the output of the above code ? Choose the correct option. A. 20 20 B. 30 20 C. 10 20 D. 20 30 # include<stdio.h> int a = 10; int main(void) { { a = 30; { { a = 20; printf("%d", a); } } printf("%d", a); } return 0; } Technical Training (C Basics) Accenture
  • 32. 1 2 3 4 5 6 What would be the output of the above code ? Choose the correct option. A. 28 B. 25 C. 29 D. 30 #include<stdio.h> int main(void) { int a = 7; int s = a++ + ++a + a-- + a % 2; printf("%d", s); } Technical Training (C Basics) TCS
  • 33. 1 2 3 4 5 6 What would be the output of the above code ? Choose the correct option. A. 28 B. 25 C. 29 D. 30 #include<stdio.h> int main(void) { int a = 7; int s = a++ + ++a + a-- + a % 2; printf("%d", s); } Technical Training (C Basics) TCS
  • 34. 1 2 3 4 5 6 7 8 9 What would be the output of the above code ? Choose the correct option. A. 2 1 1 B. 3 2 1 C. 3 1 1 D. 2 2 1 #include<stdio.h> int main(void) { int i = 1, j = 2, k, l = 1; { k = i++ + ++i + j || l++; printf("%d %d %d", i, l, k); } return 0; } Technical Training (C Basics) Capegemini
  • 35. 1 2 3 4 5 6 7 8 9 What would be the output of the above code ? Choose the correct option. A. 2 1 1 B. 3 2 1 C. 3 1 1 D. 2 2 1 #include<stdio.h> int main(void) { int i = 1, j = 2, k, l = 1; { k = i++ + ++i + j || l++; printf("%d %d %d", i, l, k); } return 0; } Technical Training (C Basics) Capegemini
  • 36. 1 2 3 4 5 6 What would be the output of the above code ? Choose the correct option. A. 3 B. 4 C. 2 D. 1 #include <stdio.h> int main(void) { int a = 5; int s = a-- || a-- && 4; printf("%d", s); } Technical Training (C Basics) Infosys
  • 37. 1 2 3 4 5 6 What would be the output of the above code ? Choose the correct option. A. 3 B. 4 C. 2 D. 1 #include <stdio.h> int main(void) { int a = 5; int s = a-- || a-- && 4; printf("%d", s); } Technical Training (C Basics) Infosys
  • 38. 1 2 3 4 5 6 7 8 9 What would be the output of the above code ? Choose the correct option. A. 1 0 2 B. 1 1 3 C. 2 0 3 D. 2 1 2 #include<stdio.h> int main(void) { int i = 0, j = 2, k, l = 0; { k = (i++ && l++ ) || j++ + i++; printf("%d %d %d", i, l, j); } return 0; } Technical Training (C Basics) Accenture
  • 39. 1 2 3 4 5 6 7 8 9 What would be the output of the above code ? Choose the correct option. A. 1 0 2 B. 1 1 3 C. 2 0 3 D. 2 1 2 #include<stdio.h> int main(void) { int i = 0, j = 2, k, l = 0; { k = (i++ && l++ ) || j++ + i++; printf("%d %d %d", i, l, j); } return 0; } Technical Training (C Basics) Accenture
  • 40. 1 2 3 4 5 6 7 8 9 10 What would be the output of the above code ? Choose the correct option. A. 4 5 B. 4 4 C. 5 4 D. 5 5 #include<stdio.h> int main(void) { int i = 10, j = 10; int k = 4; { printf("%d", sizeof(k /= i+j)); printf("%d", k) ; } return 0; } Technical Training (C Basics) Infosys
  • 41. 1 2 3 4 5 6 7 8 9 10 What would be the output of the above code ? Choose the correct option. A. 4 5 B. 4 4 C. 5 4 D. 5 5 #include<stdio.h> int main(void) { int i = 10, j = 10; int k = 4; { printf("%d", sizeof(k /= i+j)); printf("%d", k) ; } return 0; } Technical Training (C Basics) Infosys