SlideShare une entreprise Scribd logo
1  sur  18
Lecture 3Lecture 3
Version 1.0Version 1.0
Arithmetic OperatorArithmetic Operator
Relational OperatorRelational Operator
Decision MakingDecision Making
KeywordsKeywords
2Rushdi Shams, Dept of CSE, KUET, Bangladesh
Arithmetic OperatorsArithmetic Operators
 Most C programs perform arithmetic calculationsMost C programs perform arithmetic calculations
3Rushdi Shams, Dept of CSE, KUET, Bangladesh
Arithmetic operatorsArithmetic operators
 The arithmetic operators are allThe arithmetic operators are all binary operatorsbinary operators
 The expression 3+7 contains binary operator +The expression 3+7 contains binary operator +
and twoand two operandsoperands 3 and 73 and 7
 Integer division yields an integer result. 17/4 is 4Integer division yields an integer result. 17/4 is 4
 The modulus operator means the remainderThe modulus operator means the remainder
after a division operation. 17%4 is 1after a division operation. 17%4 is 1
4Rushdi Shams, Dept of CSE, KUET, Bangladesh
Rules of Operator PrecedenceRules of Operator Precedence
1.1. Expressions or portion of expressionsExpressions or portion of expressions
contained in pairs of parentheses are evaluatedcontained in pairs of parentheses are evaluated
first. In case of nested parentheses, the innerfirst. In case of nested parentheses, the inner
most parentheses will be evaluated first.most parentheses will be evaluated first.
5Rushdi Shams, Dept of CSE, KUET, Bangladesh
Rules of Operator PrecedenceRules of Operator Precedence
2.2. Multiplication, division and modulusMultiplication, division and modulus
operations are evaluated next. If an expressionoperations are evaluated next. If an expression
contains several *, / or % operations,contains several *, / or % operations,
evaluations proceed from left to right. Theseevaluations proceed from left to right. These
operators are on the same level of precedence.operators are on the same level of precedence.
6Rushdi Shams, Dept of CSE, KUET, Bangladesh
Rules of Operator PrecedenceRules of Operator Precedence
3.3. Addition and subtraction are evaluated last. IfAddition and subtraction are evaluated last. If
an expression contains several + or -an expression contains several + or -
operations, evaluations proceed from left tooperations, evaluations proceed from left to
right.right.
7Rushdi Shams, Dept of CSE, KUET, Bangladesh
Brain Storm IBrain Storm I
 m=(a+b+c+d+e)/5m=(a+b+c+d+e)/5
 m=a+b+c+d+e/5m=a+b+c+d+e/5
 What are the differences here?What are the differences here?
8Rushdi Shams, Dept of CSE, KUET, Bangladesh
Brain Storm IIBrain Storm II
 y=mx+cy=mx+c
 How do you write this expression in C? AnyHow do you write this expression in C? Any
parenthesis required?parenthesis required?
9Rushdi Shams, Dept of CSE, KUET, Bangladesh
Brain Storm IIIBrain Storm III
 z=pr%q+w/x-yz=pr%q+w/x-y
 It is in algebraic format. How will it be written inIt is in algebraic format. How will it be written in
C? What will be the order of precedence givenC? What will be the order of precedence given
by the C compiler while it is written in Cby the C compiler while it is written in C
format?format?
10Rushdi Shams, Dept of CSE, KUET, Bangladesh
Decision Making: RelationalDecision Making: Relational
OperatorsOperators
 Executable C expressions either doExecutable C expressions either do actionsactions (calculations(calculations
or input or output) or make aor input or output) or make a decisiondecision
 For example, in a program where the user will put hisFor example, in a program where the user will put his
mark and want to know if he passed or failed, you willmark and want to know if he passed or failed, you will
have to do three things-have to do three things-
1. Take the mark from the user.1. Take the mark from the user. ActionAction
2. Compare the mark with a predefined pass mark range.2. Compare the mark with a predefined pass mark range.
DecisionDecision
3. Provide that decision to user.3. Provide that decision to user. ActionAction
11Rushdi Shams, Dept of CSE, KUET, Bangladesh
Decision Making: RelationalDecision Making: Relational
OperatorsOperators
 The decision in C is done by a control structureThe decision in C is done by a control structure
calledcalled ifif
 It allows a program to make a decision based onIt allows a program to make a decision based on
the truth or falsity of some statement of factthe truth or falsity of some statement of fact
calledcalled conditioncondition
 If the condition is true,If the condition is true, the body statementthe body statement will bewill be
executed otherwise not- it will execute the nextexecuted otherwise not- it will execute the next
statement after thestatement after the ifif structurestructure
12Rushdi Shams, Dept of CSE, KUET, Bangladesh
Decision Making: RelationalDecision Making: Relational
OperatorsOperators
 Conditions inConditions in ifif structures are formed by usingstructures are formed by using
relational operatorsrelational operators
 The relational operators have the same level ofThe relational operators have the same level of
precedence and they associate left to rightprecedence and they associate left to right
 OnlyOnly equality operatorsequality operators have a lower level ofhave a lower level of
precedence than others and they also associateprecedence than others and they also associate
left to rightleft to right
13Rushdi Shams, Dept of CSE, KUET, Bangladesh
Decision Making: RelationalDecision Making: Relational
OperatorsOperators
14Rushdi Shams, Dept of CSE, KUET, Bangladesh
Decision Making: RelationalDecision Making: Relational
OperatorsOperators
 There is a subtle difference between == and =.There is a subtle difference between == and =.
In case of =, it is associated from right to left.In case of =, it is associated from right to left.
a=b means the value of b is assigned to aa=b means the value of b is assigned to a
15Rushdi Shams, Dept of CSE, KUET, Bangladesh
Decision Making: RelationalDecision Making: Relational
OperatorsOperators
#include <stdio.h>#include <stdio.h>
#include <conio.h>#include <conio.h>
void main(){void main(){
clrscr();clrscr();
int num1, num2;int num1, num2;
printf(“Enter two numbers to compare: ”);printf(“Enter two numbers to compare: ”);
scanf(“%d %d”, &num1, &num2);scanf(“%d %d”, &num1, &num2);
if(num1 == num2)if(num1 == num2)
printf(“%d and %d are equal”, num1, num2);printf(“%d and %d are equal”, num1, num2);
if(num1 != num2)if(num1 != num2)
printf(“%d and %d are not equal”, num1, num2);printf(“%d and %d are not equal”, num1, num2);
if(num1 < num2)if(num1 < num2)
printf(“%d is less than %d”, num1, num2);printf(“%d is less than %d”, num1, num2);
if(num1 > num2)if(num1 > num2)
printf(“%d is greater than %d”, num1, num2);printf(“%d is greater than %d”, num1, num2);
if(num1 <= num2)if(num1 <= num2)
printf(“%d is less than or equal to %d”, num1, num2);printf(“%d is less than or equal to %d”, num1, num2);
if(num1 >= num2)if(num1 >= num2)
printf(“%d is greater than or equal to %d”, num1, num2);printf(“%d is greater than or equal to %d”, num1, num2);
getch();getch();
}}
16Rushdi Shams, Dept of CSE, KUET, Bangladesh
KeywordsKeywords
 intint andand ifif areare keywordskeywords oror reserved wordsreserved words in Cin C
 You cannot use them as variable names as CYou cannot use them as variable names as C
compiler processes keywords in a different waycompiler processes keywords in a different way
17Rushdi Shams, Dept of CSE, KUET, Bangladesh
KeywordsKeywords
18Rushdi Shams, Dept of CSE, KUET, Bangladesh
QsQs
1.1. Every C program must have a function. What is its name?Every C program must have a function. What is its name?
2.2. What symbols are used to contain the body of the function?What symbols are used to contain the body of the function?
3.3. With what symbol every statement ends with?With what symbol every statement ends with?
4.4. Which function displays information on the screen? WhichWhich function displays information on the screen? Which
header file is required for that function?header file is required for that function?
5.5. What does n represents?What does n represents?
6.6. Which function takes input from the user?Which function takes input from the user?
7.7. Which specifier is required to represent integer?Which specifier is required to represent integer?
8.8. Which keyword is used to make decision?Which keyword is used to make decision?
9.9. What are used to make a program readable?What are used to make a program readable?

Contenu connexe

En vedette

En vedette (12)

C language control statements
C language  control statementsC language  control statements
C language control statements
 
C –imp points
C –imp pointsC –imp points
C –imp points
 
Control structure in c
Control structure in cControl structure in c
Control structure in c
 
Chapter 2 instructions language of the computer
Chapter 2 instructions language of the computerChapter 2 instructions language of the computer
Chapter 2 instructions language of the computer
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
Abc & Ved
Abc & VedAbc & Ved
Abc & Ved
 
Computer Languages....ppt
Computer Languages....pptComputer Languages....ppt
Computer Languages....ppt
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Computer Languages.
Computer Languages.Computer Languages.
Computer Languages.
 
Operator in c programming
Operator in c programmingOperator in c programming
Operator in c programming
 
C language ppt
C language pptC language ppt
C language ppt
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 

Similaire à Lec 03. Arithmetic Operator / Relational Operator

Lec 05. While Loop
Lec 05. While LoopLec 05. While Loop
Lec 05. While LoopRushdi Shams
 
The Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsThe Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsTech
 
Lec 10. Functions (Part II)
Lec 10. Functions (Part II)Lec 10. Functions (Part II)
Lec 10. Functions (Part II)Rushdi Shams
 
Lec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory ConceptLec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory ConceptRushdi Shams
 
C Prog. - Operators and Expressions
C Prog. - Operators and ExpressionsC Prog. - Operators and Expressions
C Prog. - Operators and Expressionsvinay arora
 
Lec 07. Do-While Loop / Switch
Lec 07. Do-While Loop / SwitchLec 07. Do-While Loop / Switch
Lec 07. Do-While Loop / SwitchRushdi Shams
 
Basic of Programming (Introduction to Programming)
Basic of Programming (Introduction to Programming)Basic of Programming (Introduction to Programming)
Basic of Programming (Introduction to Programming)JohnNama
 
Object Oriented Programming Short Notes for Preperation of Exams
Object Oriented Programming Short Notes for Preperation of ExamsObject Oriented Programming Short Notes for Preperation of Exams
Object Oriented Programming Short Notes for Preperation of ExamsMuhammadTalha436
 
Iaetsd protecting privacy preserving for cost effective adaptive actions
Iaetsd protecting  privacy preserving for cost effective adaptive actionsIaetsd protecting  privacy preserving for cost effective adaptive actions
Iaetsd protecting privacy preserving for cost effective adaptive actionsIaetsd Iaetsd
 
Lec 04. If-Else Statement / Increment and Decrement Operators
Lec 04. If-Else Statement / Increment and Decrement OperatorsLec 04. If-Else Statement / Increment and Decrement Operators
Lec 04. If-Else Statement / Increment and Decrement OperatorsRushdi Shams
 
IRJET- Personality Prediction System using AI
IRJET- Personality Prediction System using AIIRJET- Personality Prediction System using AI
IRJET- Personality Prediction System using AIIRJET Journal
 
Overview of a Self-Adaptive Workflow System
Overview of a Self-Adaptive Workflow SystemOverview of a Self-Adaptive Workflow System
Overview of a Self-Adaptive Workflow SystemLuca Sabatucci
 

Similaire à Lec 03. Arithmetic Operator / Relational Operator (20)

Lec 05. While Loop
Lec 05. While LoopLec 05. While Loop
Lec 05. While Loop
 
The Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsThe Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming Concepts
 
C programming
C programmingC programming
C programming
 
Lec 10. Functions (Part II)
Lec 10. Functions (Part II)Lec 10. Functions (Part II)
Lec 10. Functions (Part II)
 
Lec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory ConceptLec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory Concept
 
Unit1
Unit1Unit1
Unit1
 
C Prog. - Operators and Expressions
C Prog. - Operators and ExpressionsC Prog. - Operators and Expressions
C Prog. - Operators and Expressions
 
Lec 07. Do-While Loop / Switch
Lec 07. Do-While Loop / SwitchLec 07. Do-While Loop / Switch
Lec 07. Do-While Loop / Switch
 
Introduction to algorithms
Introduction to algorithmsIntroduction to algorithms
Introduction to algorithms
 
Basic of Programming (Introduction to Programming)
Basic of Programming (Introduction to Programming)Basic of Programming (Introduction to Programming)
Basic of Programming (Introduction to Programming)
 
Object Oriented Programming Short Notes for Preperation of Exams
Object Oriented Programming Short Notes for Preperation of ExamsObject Oriented Programming Short Notes for Preperation of Exams
Object Oriented Programming Short Notes for Preperation of Exams
 
jhtp9_ch04.ppt
jhtp9_ch04.pptjhtp9_ch04.ppt
jhtp9_ch04.ppt
 
Unit 2
Unit 2Unit 2
Unit 2
 
Iaetsd protecting privacy preserving for cost effective adaptive actions
Iaetsd protecting  privacy preserving for cost effective adaptive actionsIaetsd protecting  privacy preserving for cost effective adaptive actions
Iaetsd protecting privacy preserving for cost effective adaptive actions
 
Lec 04. If-Else Statement / Increment and Decrement Operators
Lec 04. If-Else Statement / Increment and Decrement OperatorsLec 04. If-Else Statement / Increment and Decrement Operators
Lec 04. If-Else Statement / Increment and Decrement Operators
 
Java Programming Materials
Java Programming MaterialsJava Programming Materials
Java Programming Materials
 
IRJET- Personality Prediction System using AI
IRJET- Personality Prediction System using AIIRJET- Personality Prediction System using AI
IRJET- Personality Prediction System using AI
 
slides03.ppt
slides03.pptslides03.ppt
slides03.ppt
 
Overview of a Self-Adaptive Workflow System
Overview of a Self-Adaptive Workflow SystemOverview of a Self-Adaptive Workflow System
Overview of a Self-Adaptive Workflow System
 
Fuzzy logic
Fuzzy logicFuzzy logic
Fuzzy logic
 

Plus de Rushdi Shams

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchRushdi Shams
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IRRushdi Shams
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101Rushdi Shams
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processingRushdi Shams
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: ParsingRushdi Shams
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translationRushdi Shams
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translationRushdi Shams
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semanticsRushdi Shams
 
Propositional logic
Propositional logicPropositional logic
Propositional logicRushdi Shams
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logicRushdi Shams
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structureRushdi Shams
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representationRushdi Shams
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hackingRushdi Shams
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)Rushdi Shams
 

Plus de Rushdi Shams (20)

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better Research
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IR
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processing
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: Parsing
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translation
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translation
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semantics
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logic
 
L15 fuzzy logic
L15  fuzzy logicL15  fuzzy logic
L15 fuzzy logic
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structure
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
 
First order logic
First order logicFirst order logic
First order logic
 
Belief function
Belief functionBelief function
Belief function
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hacking
 
L4 vpn
L4  vpnL4  vpn
L4 vpn
 
L3 defense
L3  defenseL3  defense
L3 defense
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)
 
L1 phishing
L1  phishingL1  phishing
L1 phishing
 

Dernier

AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 

Dernier (20)

AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 

Lec 03. Arithmetic Operator / Relational Operator

  • 1. Lecture 3Lecture 3 Version 1.0Version 1.0 Arithmetic OperatorArithmetic Operator Relational OperatorRelational Operator Decision MakingDecision Making KeywordsKeywords
  • 2. 2Rushdi Shams, Dept of CSE, KUET, Bangladesh Arithmetic OperatorsArithmetic Operators  Most C programs perform arithmetic calculationsMost C programs perform arithmetic calculations
  • 3. 3Rushdi Shams, Dept of CSE, KUET, Bangladesh Arithmetic operatorsArithmetic operators  The arithmetic operators are allThe arithmetic operators are all binary operatorsbinary operators  The expression 3+7 contains binary operator +The expression 3+7 contains binary operator + and twoand two operandsoperands 3 and 73 and 7  Integer division yields an integer result. 17/4 is 4Integer division yields an integer result. 17/4 is 4  The modulus operator means the remainderThe modulus operator means the remainder after a division operation. 17%4 is 1after a division operation. 17%4 is 1
  • 4. 4Rushdi Shams, Dept of CSE, KUET, Bangladesh Rules of Operator PrecedenceRules of Operator Precedence 1.1. Expressions or portion of expressionsExpressions or portion of expressions contained in pairs of parentheses are evaluatedcontained in pairs of parentheses are evaluated first. In case of nested parentheses, the innerfirst. In case of nested parentheses, the inner most parentheses will be evaluated first.most parentheses will be evaluated first.
  • 5. 5Rushdi Shams, Dept of CSE, KUET, Bangladesh Rules of Operator PrecedenceRules of Operator Precedence 2.2. Multiplication, division and modulusMultiplication, division and modulus operations are evaluated next. If an expressionoperations are evaluated next. If an expression contains several *, / or % operations,contains several *, / or % operations, evaluations proceed from left to right. Theseevaluations proceed from left to right. These operators are on the same level of precedence.operators are on the same level of precedence.
  • 6. 6Rushdi Shams, Dept of CSE, KUET, Bangladesh Rules of Operator PrecedenceRules of Operator Precedence 3.3. Addition and subtraction are evaluated last. IfAddition and subtraction are evaluated last. If an expression contains several + or -an expression contains several + or - operations, evaluations proceed from left tooperations, evaluations proceed from left to right.right.
  • 7. 7Rushdi Shams, Dept of CSE, KUET, Bangladesh Brain Storm IBrain Storm I  m=(a+b+c+d+e)/5m=(a+b+c+d+e)/5  m=a+b+c+d+e/5m=a+b+c+d+e/5  What are the differences here?What are the differences here?
  • 8. 8Rushdi Shams, Dept of CSE, KUET, Bangladesh Brain Storm IIBrain Storm II  y=mx+cy=mx+c  How do you write this expression in C? AnyHow do you write this expression in C? Any parenthesis required?parenthesis required?
  • 9. 9Rushdi Shams, Dept of CSE, KUET, Bangladesh Brain Storm IIIBrain Storm III  z=pr%q+w/x-yz=pr%q+w/x-y  It is in algebraic format. How will it be written inIt is in algebraic format. How will it be written in C? What will be the order of precedence givenC? What will be the order of precedence given by the C compiler while it is written in Cby the C compiler while it is written in C format?format?
  • 10. 10Rushdi Shams, Dept of CSE, KUET, Bangladesh Decision Making: RelationalDecision Making: Relational OperatorsOperators  Executable C expressions either doExecutable C expressions either do actionsactions (calculations(calculations or input or output) or make aor input or output) or make a decisiondecision  For example, in a program where the user will put hisFor example, in a program where the user will put his mark and want to know if he passed or failed, you willmark and want to know if he passed or failed, you will have to do three things-have to do three things- 1. Take the mark from the user.1. Take the mark from the user. ActionAction 2. Compare the mark with a predefined pass mark range.2. Compare the mark with a predefined pass mark range. DecisionDecision 3. Provide that decision to user.3. Provide that decision to user. ActionAction
  • 11. 11Rushdi Shams, Dept of CSE, KUET, Bangladesh Decision Making: RelationalDecision Making: Relational OperatorsOperators  The decision in C is done by a control structureThe decision in C is done by a control structure calledcalled ifif  It allows a program to make a decision based onIt allows a program to make a decision based on the truth or falsity of some statement of factthe truth or falsity of some statement of fact calledcalled conditioncondition  If the condition is true,If the condition is true, the body statementthe body statement will bewill be executed otherwise not- it will execute the nextexecuted otherwise not- it will execute the next statement after thestatement after the ifif structurestructure
  • 12. 12Rushdi Shams, Dept of CSE, KUET, Bangladesh Decision Making: RelationalDecision Making: Relational OperatorsOperators  Conditions inConditions in ifif structures are formed by usingstructures are formed by using relational operatorsrelational operators  The relational operators have the same level ofThe relational operators have the same level of precedence and they associate left to rightprecedence and they associate left to right  OnlyOnly equality operatorsequality operators have a lower level ofhave a lower level of precedence than others and they also associateprecedence than others and they also associate left to rightleft to right
  • 13. 13Rushdi Shams, Dept of CSE, KUET, Bangladesh Decision Making: RelationalDecision Making: Relational OperatorsOperators
  • 14. 14Rushdi Shams, Dept of CSE, KUET, Bangladesh Decision Making: RelationalDecision Making: Relational OperatorsOperators  There is a subtle difference between == and =.There is a subtle difference between == and =. In case of =, it is associated from right to left.In case of =, it is associated from right to left. a=b means the value of b is assigned to aa=b means the value of b is assigned to a
  • 15. 15Rushdi Shams, Dept of CSE, KUET, Bangladesh Decision Making: RelationalDecision Making: Relational OperatorsOperators #include <stdio.h>#include <stdio.h> #include <conio.h>#include <conio.h> void main(){void main(){ clrscr();clrscr(); int num1, num2;int num1, num2; printf(“Enter two numbers to compare: ”);printf(“Enter two numbers to compare: ”); scanf(“%d %d”, &num1, &num2);scanf(“%d %d”, &num1, &num2); if(num1 == num2)if(num1 == num2) printf(“%d and %d are equal”, num1, num2);printf(“%d and %d are equal”, num1, num2); if(num1 != num2)if(num1 != num2) printf(“%d and %d are not equal”, num1, num2);printf(“%d and %d are not equal”, num1, num2); if(num1 < num2)if(num1 < num2) printf(“%d is less than %d”, num1, num2);printf(“%d is less than %d”, num1, num2); if(num1 > num2)if(num1 > num2) printf(“%d is greater than %d”, num1, num2);printf(“%d is greater than %d”, num1, num2); if(num1 <= num2)if(num1 <= num2) printf(“%d is less than or equal to %d”, num1, num2);printf(“%d is less than or equal to %d”, num1, num2); if(num1 >= num2)if(num1 >= num2) printf(“%d is greater than or equal to %d”, num1, num2);printf(“%d is greater than or equal to %d”, num1, num2); getch();getch(); }}
  • 16. 16Rushdi Shams, Dept of CSE, KUET, Bangladesh KeywordsKeywords  intint andand ifif areare keywordskeywords oror reserved wordsreserved words in Cin C  You cannot use them as variable names as CYou cannot use them as variable names as C compiler processes keywords in a different waycompiler processes keywords in a different way
  • 17. 17Rushdi Shams, Dept of CSE, KUET, Bangladesh KeywordsKeywords
  • 18. 18Rushdi Shams, Dept of CSE, KUET, Bangladesh QsQs 1.1. Every C program must have a function. What is its name?Every C program must have a function. What is its name? 2.2. What symbols are used to contain the body of the function?What symbols are used to contain the body of the function? 3.3. With what symbol every statement ends with?With what symbol every statement ends with? 4.4. Which function displays information on the screen? WhichWhich function displays information on the screen? Which header file is required for that function?header file is required for that function? 5.5. What does n represents?What does n represents? 6.6. Which function takes input from the user?Which function takes input from the user? 7.7. Which specifier is required to represent integer?Which specifier is required to represent integer? 8.8. Which keyword is used to make decision?Which keyword is used to make decision? 9.9. What are used to make a program readable?What are used to make a program readable?