SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
COMPUTER PROGRAMMING
Imtiaz Ali
INTRODUCTION TO COMPUTER PROGRAMMING
1) Operators, Arithmetic and Arithmetic assignment operators.
2) Increment Operator, Decrement Operator.
3) Relational Operator.
Operators
• Operators are words or symbols that cause a program to do
something to variables.
• For example, the arithmetic operators (+) and (-) cause a
program to add or subtract two numbers.
Many different kind of operators
• + Addition
• - Subtraction
• * Multiplication
• / Division
• % Remainder
Fahrenheit to Celsius Temperature conversion
#include<stdio.h>
void main(void)
{
int ftemp,ctemp;
pritnf((“Type temperature in degree fahrenheit”);
scanf((“%d”,&ftemp);
ctemp=(ftemp-32)*5/9;
printf(“Temperature in degree Celsius is %d”,ctemp);
}
Celsius to Fahrenheit Temperature conversion
#include<stdio.h>
void main(void)
{
int ftemp,ctemp;
pritnf((“Type temperature in degree fahrenheit”);
printf(“Temperature in degree Celsius is %d”,ctemp);
}
Operator Precedence
• We have parenthesis around f(temp-32) known as precedence.
• The fact (*) abd (/) are evaluated before(+) and(-).
• We say that (*) and (/) has higher precedence than (+) and (-).
Remainder Operator
• Remainder operator(sometimes called modulor operator)
may be unfamiliar to you.
• It is used to find remainder when one number is divided by
another
• For example answer=13%5
value is 3
Expressions versus Variables
Days=years*365;
void main(void)
{
int num=2;
printf(“Number plus four is”,num+4);
}
Arithmetic Assignment Operator
Syntax:
Arithmetic op=
• += (Addition Assignment Operator)
• -= (Subtraction Assignment Operator)
• *= (Multiplication Assignment Operator)
• /= (Division Assignment Operator)
• %= (Remainder Assignment Operator)
• a+=1 is same as=> a=a+1
• a-=1 is same as=> a=a-1
• a*=1 is same as=> a=a*1
• a/=1 is same as=> a=a/1
• a%=1 is same as a=a%1
Increment Operator
+=,-=,++,--
+=(Addition Assignment Operator)
It is also known as increment operator
Syntax:
variable+=value;
variable=variable+value
-=(Subtraction Assignment Operator)
It is also known as increment operator
Syntax:
Variable-=value;
variable=variable-value
• Postfix increment and Postfix decrement Operator
• Prefix increment and Prefix decrement Operator
Op++
• It is postfix increment operator
++Op
• It is prefix increment operator
Op--
• It is postfix decrement operator
--Op
• It is prefix decrement operator
variable++ as postfix increment operator
#include<stdio.h>
void main(void)
{
int num=0;
printf(“Number=%dn”,num);
printf(“Number=%dn”,num++);
printf(“Number=%dn”,num);
}
++variable as prefix increment operator
#include<stdio.h>
void main(void)
{
int num=0;
printf(“Number=%dn”,num);
printf(“Number=%dn”,++num);
printf(“Number=%dn”,num);
}
variable-- as Postfix decrement operator
#include<stdio.h>
void main(void)
{
int num=0;
printf(“Number=%dn”,num);
printf(“Number=%dn”,num--);
printf(“Number=%dn”,num);
}
--variable as Prefix decrement operator
#include<stdio.h>
void main(void)
{
int num=0;
printf(“Number=%dn”,num);
printf(“Number=%dn”,--num);
printf(“Number=%dn”,num);
}
Relational Operators
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal to
&& Logical AND or short circuit AND
|| Logical OR or short circuit OR

More Related Content

What's hot (20)

PPTX
2- Dimensional Arrays
Education Front
 
PPTX
Introduction of c programming
Tarun Sharma
 
PPTX
Dijkstra's Algorithm
Tamzida_Azad
 
PDF
SPL 2 | Algorithms, Pseudo-code, and Flowchart
Mohammad Imam Hossain
 
PPTX
Number system
aviban
 
PPTX
Queue Implementation Using Array & Linked List
PTCL
 
PPTX
Python Programming Essentials - M6 - Code Blocks and Indentation
P3 InfoTech Solutions Pvt. Ltd.
 
PPTX
Prefix, Infix and Post-fix Notations
Afaq Mansoor Khan
 
PDF
CP Handout#4
trupti1976
 
PPT
Arithmetic for Computers.ppt
JEEVANANTHAMG6
 
PDF
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...
Edureka!
 
PPTX
Algorithms and Flowcharts
Deva Singh
 
PPTX
Pseudo code
Arindam Ghosh
 
PPTX
Chapter 10 data handling
Praveen M Jigajinni
 
PPTX
Python
Gagandeep Nanda
 
PPT
introduction to_trees
Danish Aakash
 
PPTX
Nested loops
Neeru Mittal
 
PPTX
11 Unit1 Chapter 1 Getting Started With Python
Praveen M Jigajinni
 
PPT
Searching algorithms
Trupti Agrawal
 
PPTX
Flowchart and algorithm
Sayali Shivarkar
 
2- Dimensional Arrays
Education Front
 
Introduction of c programming
Tarun Sharma
 
Dijkstra's Algorithm
Tamzida_Azad
 
SPL 2 | Algorithms, Pseudo-code, and Flowchart
Mohammad Imam Hossain
 
Number system
aviban
 
Queue Implementation Using Array & Linked List
PTCL
 
Python Programming Essentials - M6 - Code Blocks and Indentation
P3 InfoTech Solutions Pvt. Ltd.
 
Prefix, Infix and Post-fix Notations
Afaq Mansoor Khan
 
CP Handout#4
trupti1976
 
Arithmetic for Computers.ppt
JEEVANANTHAMG6
 
Python Projects For Beginners | Python Projects Examples | Python Tutorial | ...
Edureka!
 
Algorithms and Flowcharts
Deva Singh
 
Pseudo code
Arindam Ghosh
 
Chapter 10 data handling
Praveen M Jigajinni
 
introduction to_trees
Danish Aakash
 
Nested loops
Neeru Mittal
 
11 Unit1 Chapter 1 Getting Started With Python
Praveen M Jigajinni
 
Searching algorithms
Trupti Agrawal
 
Flowchart and algorithm
Sayali Shivarkar
 

Similar to Arithmetic and Arithmetic assignment operators (20)

PPT
operators and arithmatic expression in C Language
ParamesswariNataraja
 
PPT
Operators in c language
Amit Singh
 
PPTX
Operator in programming in C engineering
roysimran2007
 
PPTX
Simran Roy Operator in Programming in C Language
simranroy370
 
PPT
Operators
Kamran
 
PPTX
Operators
Krishna Kumar Pankaj
 
PPTX
lec 2operators introduction to operators
FatimaAijaz6
 
PPTX
Operators1.pptx
HARSHSHARMA840
 
PPT
C Sharp Jn (2)
jahanullah
 
PPT
C Sharp Jn (2)
guest58c84c
 
PPTX
Chapter 3.3
sotlsoc
 
PPT
c-programming
Zulhazmi Harith
 
PPTX
object oriented programming presentation
Mahesh_gmail_KNL Na
 
PPTX
OPERATORS IN C.pptx
Ponmeenakshi1
 
PPTX
OPERATORS IN C.pptx
AshokJ19
 
PDF
2 EPT 162 Lecture 2
Don Dooley
 
PPTX
Operators and expressions in C++
Neeru Mittal
 
PPTX
Csc240 -lecture_5
Ainuddin Yousufzai
 
PDF
Types of Operators in C programming .pdf
RichardMathengeSPASP
 
PPTX
Operator in c
ankush9927
 
operators and arithmatic expression in C Language
ParamesswariNataraja
 
Operators in c language
Amit Singh
 
Operator in programming in C engineering
roysimran2007
 
Simran Roy Operator in Programming in C Language
simranroy370
 
Operators
Kamran
 
lec 2operators introduction to operators
FatimaAijaz6
 
Operators1.pptx
HARSHSHARMA840
 
C Sharp Jn (2)
jahanullah
 
C Sharp Jn (2)
guest58c84c
 
Chapter 3.3
sotlsoc
 
c-programming
Zulhazmi Harith
 
object oriented programming presentation
Mahesh_gmail_KNL Na
 
OPERATORS IN C.pptx
Ponmeenakshi1
 
OPERATORS IN C.pptx
AshokJ19
 
2 EPT 162 Lecture 2
Don Dooley
 
Operators and expressions in C++
Neeru Mittal
 
Csc240 -lecture_5
Ainuddin Yousufzai
 
Types of Operators in C programming .pdf
RichardMathengeSPASP
 
Operator in c
ankush9927
 
Ad

More from imtiazalijoono (20)

PDF
Embedded systems io programming
imtiazalijoono
 
PDF
Embedded systems tools & peripherals
imtiazalijoono
 
PPTX
Importance of reading and its types.
imtiazalijoono
 
PPTX
Negative amplifiers and its types Positive feedback and Negative feedback
imtiazalijoono
 
PPTX
Multistage amplifiers and Name of coupling Name of multistage amplifier
imtiazalijoono
 
PDF
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
imtiazalijoono
 
PDF
Programming Fundamentals and basic knowledge
imtiazalijoono
 
PDF
Programming Fundamentals Functions in C and types
imtiazalijoono
 
PDF
Software Development Software development process
imtiazalijoono
 
PDF
Programming Fundamentals Decisions
imtiazalijoono
 
PDF
C Building Blocks
imtiazalijoono
 
PDF
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
PPTX
Programming Fundamentals and Programming Languages Concepts Translators
imtiazalijoono
 
PPTX
Programming Fundamentals and Programming Languages Concepts
imtiazalijoono
 
DOCX
Programming Global variable
imtiazalijoono
 
PPTX
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
PPTX
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
imtiazalijoono
 
PPTX
INTRODUCTION TO COMPUTER PROGRAMMING
imtiazalijoono
 
PPTX
COMPUTER PROGRAMMING
imtiazalijoono
 
PPTX
COMPUTER PROGRAMMING
imtiazalijoono
 
Embedded systems io programming
imtiazalijoono
 
Embedded systems tools & peripherals
imtiazalijoono
 
Importance of reading and its types.
imtiazalijoono
 
Negative amplifiers and its types Positive feedback and Negative feedback
imtiazalijoono
 
Multistage amplifiers and Name of coupling Name of multistage amplifier
imtiazalijoono
 
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
imtiazalijoono
 
Programming Fundamentals and basic knowledge
imtiazalijoono
 
Programming Fundamentals Functions in C and types
imtiazalijoono
 
Software Development Software development process
imtiazalijoono
 
Programming Fundamentals Decisions
imtiazalijoono
 
C Building Blocks
imtiazalijoono
 
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
Programming Fundamentals and Programming Languages Concepts Translators
imtiazalijoono
 
Programming Fundamentals and Programming Languages Concepts
imtiazalijoono
 
Programming Global variable
imtiazalijoono
 
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,
imtiazalijoono
 
INTRODUCTION TO COMPUTER PROGRAMMING
imtiazalijoono
 
COMPUTER PROGRAMMING
imtiazalijoono
 
COMPUTER PROGRAMMING
imtiazalijoono
 
Ad

Recently uploaded (20)

PPTX
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PDF
monopile foundation seminar topic for civil engineering students
Ahina5
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PDF
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PDF
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PPTX
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PDF
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
PPTX
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PPTX
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
PDF
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
PDF
Statistical Data Analysis Using SPSS Software
shrikrishna kesharwani
 
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
monopile foundation seminar topic for civil engineering students
Ahina5
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
REINFORCEMENT AS CONSTRUCTION MATERIALS.pptx
mohaiminulhaquesami
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
POWER PLANT ENGINEERING (R17A0326).pdf..
haneefachosa123
 
Hashing Introduction , hash functions and techniques
sailajam21
 
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
Innowell Capability B0425 - Commercial Buildings.pptx
regobertroza
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Break Statement in Programming with 6 Real Examples
manojpoojary2004
 
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
Statistical Data Analysis Using SPSS Software
shrikrishna kesharwani
 

Arithmetic and Arithmetic assignment operators

  • 2. INTRODUCTION TO COMPUTER PROGRAMMING 1) Operators, Arithmetic and Arithmetic assignment operators. 2) Increment Operator, Decrement Operator. 3) Relational Operator.
  • 3. Operators • Operators are words or symbols that cause a program to do something to variables. • For example, the arithmetic operators (+) and (-) cause a program to add or subtract two numbers. Many different kind of operators • + Addition • - Subtraction • * Multiplication • / Division • % Remainder
  • 4. Fahrenheit to Celsius Temperature conversion #include<stdio.h> void main(void) { int ftemp,ctemp; pritnf((“Type temperature in degree fahrenheit”); scanf((“%d”,&ftemp); ctemp=(ftemp-32)*5/9; printf(“Temperature in degree Celsius is %d”,ctemp); }
  • 5. Celsius to Fahrenheit Temperature conversion #include<stdio.h> void main(void) { int ftemp,ctemp; pritnf((“Type temperature in degree fahrenheit”); printf(“Temperature in degree Celsius is %d”,ctemp); }
  • 6. Operator Precedence • We have parenthesis around f(temp-32) known as precedence. • The fact (*) abd (/) are evaluated before(+) and(-). • We say that (*) and (/) has higher precedence than (+) and (-). Remainder Operator • Remainder operator(sometimes called modulor operator) may be unfamiliar to you. • It is used to find remainder when one number is divided by another • For example answer=13%5 value is 3
  • 7. Expressions versus Variables Days=years*365; void main(void) { int num=2; printf(“Number plus four is”,num+4); }
  • 8. Arithmetic Assignment Operator Syntax: Arithmetic op= • += (Addition Assignment Operator) • -= (Subtraction Assignment Operator) • *= (Multiplication Assignment Operator) • /= (Division Assignment Operator) • %= (Remainder Assignment Operator) • a+=1 is same as=> a=a+1 • a-=1 is same as=> a=a-1 • a*=1 is same as=> a=a*1 • a/=1 is same as=> a=a/1 • a%=1 is same as a=a%1
  • 9. Increment Operator +=,-=,++,-- +=(Addition Assignment Operator) It is also known as increment operator Syntax: variable+=value; variable=variable+value -=(Subtraction Assignment Operator) It is also known as increment operator Syntax: Variable-=value; variable=variable-value
  • 10. • Postfix increment and Postfix decrement Operator • Prefix increment and Prefix decrement Operator Op++ • It is postfix increment operator ++Op • It is prefix increment operator Op-- • It is postfix decrement operator --Op • It is prefix decrement operator
  • 11. variable++ as postfix increment operator #include<stdio.h> void main(void) { int num=0; printf(“Number=%dn”,num); printf(“Number=%dn”,num++); printf(“Number=%dn”,num); }
  • 12. ++variable as prefix increment operator #include<stdio.h> void main(void) { int num=0; printf(“Number=%dn”,num); printf(“Number=%dn”,++num); printf(“Number=%dn”,num); }
  • 13. variable-- as Postfix decrement operator #include<stdio.h> void main(void) { int num=0; printf(“Number=%dn”,num); printf(“Number=%dn”,num--); printf(“Number=%dn”,num); }
  • 14. --variable as Prefix decrement operator #include<stdio.h> void main(void) { int num=0; printf(“Number=%dn”,num); printf(“Number=%dn”,--num); printf(“Number=%dn”,num); }
  • 15. Relational Operators < Less than > Greater than <= Less than or equal to >= Greater than or equal to == Equal to != Not equal to && Logical AND or short circuit AND || Logical OR or short circuit OR