SlideShare a Scribd company logo
Meet Our Group:
AZWAD HUSSAIN SHADMAN- 2023331504
JANNATUL FERDOUS MARIA- 2023331512
MOHAMMAD R RAFI CHOWDHURY- 2023331525
COMPUTER SCIENCE AND ENGINEERING
PRESENTATION
PRESENTING TO :
Md Lysuzzaman
Lecturer, Dept. Of CSE, SYLHET ENGINEERING
COLLEGE
Topics Overview :
We Will discuss about 3 Operators in C
Language :
Topics Overview :
1.Assignment Operator
2.Increment & Decrement Operator
3. Conditional Operator
Assignment Operator :
The assignment operator (=) assigns a value to a
variable.
assignment operators :
- assigns values from right to left.
- Make code shorter and more readable.
Types Of Assignment Operator :
- Simple Assignment Operator (=)
- Compund Assignment Operators (+=, -=, *=, /=, %=)
Examples :
Example 1 : Simple Assignment Operator
Output :
the value of a is 5
#include<stdio.h>
int main(){
int a;
a=5; // assigning 5 to a
printf(“the value of a is %d”,a);
return 0;
}
Example 2 : Compund Assignment Operator
Output :
a after += :10
a after *= :20
#include<stdio.h>
int main() {
int a=5;
a+=5; // same as a=a+5
printf(“a after += %d n”,a);
a*=2; // same as a=a*2
printf(“a after *= : %d”,a);
return 0;
}
Increment and Decrement Operator :
Increment(++) and decrement(--) operators are used to
increase or decrease
a variables value by 1
These operators are commonly used in
Loops(for,while)
&
Counters
1.Increment Operator(++) :
The increment operator (++) increase the value of a variable by 1
There are two types of increment operators :
1.Pre-Increment(++variable):
Increases the variable’s value before using it in an expression
2.Post-Increment(variable++):
Uses the variables current value in an expression,then increases it
Example of Increment Operator
#include<stdio.h>
int main(){
int a=5;
printf(“Pre-increment :%dn”,++a); //increment
first,then print
printf(“Post-increment :%dn”,a++);//prints first then
increment
printf(“Value after Post-Increment:%d”,a);
return 0;
}
output:
Pre-increment :6
Post-increment :6
Value after Post-
Increment:7
2. Decrement Operator (--):
The decrement operator (--) decreases the value of a variable by 1
There are two types of Decrement Operators:
1.Pre-Decrement (--variable):
Decreases the variable’s value before using it.
2. Post-Decrement (variable--):
Uses the variable’s current value in an expression, then decreases it.
#include <stdio.h>
int main() {
int a = 10;
printf("Pre-Decrement: %dn", --a); // Decrements first, then
prints (9)
printf("Post-Decrement: %dn", a--); // Prints first (9), then
decrements
printf("Value after Post-Decrement: %dn", a); // Now a=8
return 0;
}
Output:
Pre-Decrement:9
Post-Decrement:9
Value after Post-
Decrement:8
Example of Decrement Operator:
Conditional Operator (?:):
The conditional operator is a shorthand for if-else
statements.
also known as the ternary operator.
It allows you to write conditional expressions in a more
concise way.
The conditional operator is faster and more concise than if-
else.
it’s useful for simple conditions like min/max selection and
checking conditions.
Syntax :
condition ? expression1 : expression2;
If condition is true (non-zero),
expression1 is executed.
If condition is false (zero),
expression2 is executed.
Example 1 :(Maximum and minimum)
#include<stdio.h>
int main() {
int a=10, b=20;
Int min=(a<b) ? a : b; //finds the smaller number
printf(“Minimum value:%dn”,min);
return 0;
}
Output:
Minimum value:10
Since a<b is true ,a is assigned to min
Example 2: Checking Even or Odd
#include <stdio.h>
int main() {
int num = 9;
printf("%d is %sn", num, (num % 2 == 0) ? "Even" : "Odd");
return 0;
}
Output:
9 is odd
QNA
THE END
Thank You For Your
Attention!

More Related Content

PPTX
Operators-computer programming and utilzation
PPTX
Operators1.pptx
PDF
Types of Operators in C programming .pdf
PPTX
Understanding operators in c language.pptx
PPTX
Understanding Operators in C Programming – Logic Development PPT
PPT
Operators in C Programming
PDF
C Operators and Control Structures.pdf
PPTX
Operators inc c language
Operators-computer programming and utilzation
Operators1.pptx
Types of Operators in C programming .pdf
Understanding operators in c language.pptx
Understanding Operators in C Programming – Logic Development PPT
Operators in C Programming
C Operators and Control Structures.pdf
Operators inc c language

Similar to presentation of c language. with ternary operator (20)

PPTX
Operators and expressions in c language
PPTX
introduction to c programming and C History.pptx
PPTX
Chapter 3.3
PDF
2 EPT 162 Lecture 2
PPTX
C Operators and Control Structures.pptx
DOC
Unit 4 (1)
PPTX
Operator overloading
PPTX
PROGRAMMING IN C - Operators.pptx
PDF
Programming for Problem Solving
PPTX
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
PDF
ICP - Lecture 5
PPTX
Presentation on Function in C Programming
PPTX
This slide contains information about Operators in C.pptx
PPT
Operators in Computer programming presentation
PPT
C operators
DOCX
C – operators and expressions
PPTX
PPT
Operators in c language
PPTX
operators.pptx
Operators and expressions in c language
introduction to c programming and C History.pptx
Chapter 3.3
2 EPT 162 Lecture 2
C Operators and Control Structures.pptx
Unit 4 (1)
Operator overloading
PROGRAMMING IN C - Operators.pptx
Programming for Problem Solving
Unit 1- PROGRAMMING IN C OPERATORS LECTURER NOTES
ICP - Lecture 5
Presentation on Function in C Programming
This slide contains information about Operators in C.pptx
Operators in Computer programming presentation
C operators
C – operators and expressions
Operators in c language
operators.pptx
Ad

Recently uploaded (20)

PPTX
Construction Project Organization Group 2.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PPT
Mechanical Engineering MATERIALS Selection
PDF
Well-logging-methods_new................
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPT
introduction to datamining and warehousing
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
composite construction of structures.pdf
PPTX
Geodesy 1.pptx...............................................
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Lecture Notes Electrical Wiring System Components
Construction Project Organization Group 2.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Automation-in-Manufacturing-Chapter-Introduction.pdf
Internet of Things (IOT) - A guide to understanding
Mechanical Engineering MATERIALS Selection
Well-logging-methods_new................
UNIT 4 Total Quality Management .pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
introduction to datamining and warehousing
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Safety Seminar civil to be ensured for safe working.
composite construction of structures.pdf
Geodesy 1.pptx...............................................
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Embodied AI: Ushering in the Next Era of Intelligent Systems
Lecture Notes Electrical Wiring System Components
Ad

presentation of c language. with ternary operator

  • 1. Meet Our Group: AZWAD HUSSAIN SHADMAN- 2023331504 JANNATUL FERDOUS MARIA- 2023331512 MOHAMMAD R RAFI CHOWDHURY- 2023331525 COMPUTER SCIENCE AND ENGINEERING PRESENTATION PRESENTING TO : Md Lysuzzaman Lecturer, Dept. Of CSE, SYLHET ENGINEERING COLLEGE
  • 2. Topics Overview : We Will discuss about 3 Operators in C Language : Topics Overview : 1.Assignment Operator 2.Increment & Decrement Operator 3. Conditional Operator
  • 3. Assignment Operator : The assignment operator (=) assigns a value to a variable. assignment operators : - assigns values from right to left. - Make code shorter and more readable. Types Of Assignment Operator : - Simple Assignment Operator (=) - Compund Assignment Operators (+=, -=, *=, /=, %=)
  • 4. Examples : Example 1 : Simple Assignment Operator Output : the value of a is 5 #include<stdio.h> int main(){ int a; a=5; // assigning 5 to a printf(“the value of a is %d”,a); return 0; }
  • 5. Example 2 : Compund Assignment Operator Output : a after += :10 a after *= :20 #include<stdio.h> int main() { int a=5; a+=5; // same as a=a+5 printf(“a after += %d n”,a); a*=2; // same as a=a*2 printf(“a after *= : %d”,a); return 0; }
  • 6. Increment and Decrement Operator : Increment(++) and decrement(--) operators are used to increase or decrease a variables value by 1 These operators are commonly used in Loops(for,while) & Counters
  • 7. 1.Increment Operator(++) : The increment operator (++) increase the value of a variable by 1 There are two types of increment operators : 1.Pre-Increment(++variable): Increases the variable’s value before using it in an expression 2.Post-Increment(variable++): Uses the variables current value in an expression,then increases it
  • 8. Example of Increment Operator #include<stdio.h> int main(){ int a=5; printf(“Pre-increment :%dn”,++a); //increment first,then print printf(“Post-increment :%dn”,a++);//prints first then increment printf(“Value after Post-Increment:%d”,a); return 0; } output: Pre-increment :6 Post-increment :6 Value after Post- Increment:7
  • 9. 2. Decrement Operator (--): The decrement operator (--) decreases the value of a variable by 1 There are two types of Decrement Operators: 1.Pre-Decrement (--variable): Decreases the variable’s value before using it. 2. Post-Decrement (variable--): Uses the variable’s current value in an expression, then decreases it.
  • 10. #include <stdio.h> int main() { int a = 10; printf("Pre-Decrement: %dn", --a); // Decrements first, then prints (9) printf("Post-Decrement: %dn", a--); // Prints first (9), then decrements printf("Value after Post-Decrement: %dn", a); // Now a=8 return 0; } Output: Pre-Decrement:9 Post-Decrement:9 Value after Post- Decrement:8 Example of Decrement Operator:
  • 11. Conditional Operator (?:): The conditional operator is a shorthand for if-else statements. also known as the ternary operator. It allows you to write conditional expressions in a more concise way. The conditional operator is faster and more concise than if- else. it’s useful for simple conditions like min/max selection and checking conditions.
  • 12. Syntax : condition ? expression1 : expression2; If condition is true (non-zero), expression1 is executed. If condition is false (zero), expression2 is executed.
  • 13. Example 1 :(Maximum and minimum) #include<stdio.h> int main() { int a=10, b=20; Int min=(a<b) ? a : b; //finds the smaller number printf(“Minimum value:%dn”,min); return 0; } Output: Minimum value:10 Since a<b is true ,a is assigned to min
  • 14. Example 2: Checking Even or Odd #include <stdio.h> int main() { int num = 9; printf("%d is %sn", num, (num % 2 == 0) ? "Even" : "Odd"); return 0; } Output: 9 is odd
  • 15. QNA
  • 16. THE END Thank You For Your Attention!