SlideShare a Scribd company logo
1 of 10
Download to read offline
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page1
Arithmetic Operator - Basic C Programming Solve
Problems…
1. (a) Write a program that read two integer and display sum.
(b) Write a program that read two floating point and display sum.
2. Write a program that subtracts two integer.
3. Write a program that read two integer and display product.
4. (a) Write a program that divide two integer.
(b) Write a program that divide two floating point
5. Write a program that read two integer and display reminder.
6. Write a program that read radius of a circle and display its area.
7. Write a program to demonstrate the working of increment and
decrement operators.
SOLVED BY
Md. Masudur Rahman
Department of Textile Engineering
4th Batch
National Institute of Textile Engineering and Research (NITER)
masudbdasia@gmail.com
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page2
Operator :Operators in C program is special symbol or word which directs the
compiler to perform arithmetical or logical works, i.e. the characters which is used in C
for special purpose so this character is called operators.
Different types of operators :
 Arithmetic operator
 Unary operator
 Relational operator
 Logical operator
 Assignment operator
 Conditional operator
Arithmetic Operators List :
Arithmetic Operators niterians.blogspot.com
Operator Meaning
+ Addition or unary plus
- Subtraction or unary minus
* Multiplication
/ Division
% Modulo division
++ Increment operator increases the integer value
by one.
-- Decrement operator decreases the integer
value by one.
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page3
Arithmetic expressions:
An arithmetic expression is a combination of variables, constants, and
operators.
For example,
Arithmetic expressions: niterians.blogspot.com
a*b-c a*b-c
(m+n)(x+y) (m+n)*(x+y)
ax2
+bx+c a*x*x+b*x+c
1) (a) Write a program that read two integer and display sum.
#include <stdio.h>
int main ()
{
int a, b, c;
printf("Enter the value of a : ");
scanf("%d", &a);
printf("Enter the value of b : ");
scanf("%d", &b);
c =a+b;
printf("Sum of a and b is %d ", c);
}
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page4
(1) (b) Write a program that read two floating point and display sum.
2) Write a program that subtracts two integer.
#include <stdio.h>
int main ()
{
float a, b, c;
printf("Enter the value of a : ");
scanf("%f", &a);
printf("Enter the value of b : ");
scanf("%f", &b);
c =a+b;
printf("Sum of a and b is %f ", c);
}
#include <stdio.h>
int main ()
{
int a, b, c;
printf("Enter the value of a :");
scanf("%d", &a);
printf("Enter the value of b :");
scanf("%d", &b);
c =a-b;
printf("a - b = %d", c);
}
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page5
2) Write a program that subtracts two integer
3) Write a program that read two integer and display product.
#include <stdio.h>
int main ()
{
int a, b, c;
printf("Enter the value of a : ");
scanf("%d", &a);
printf("Enter the value of b : ");
scanf("%d", &b);
c =a*b;
printf("Product of a and b is %d ", c);
}
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page6
(4) (a) Write a program that divide two integer.
(4) (b) Write a program that divide two floating point
#include <stdio.h>
int main ()
{
int a, b, c;
printf("Enter the value of a: ");
scanf("%d", &a);
printf("Enter the value of b: ");
scanf("%d", &b);
c =a/b;
printf("a divide b is = %d", c);
}
#include <stdio.h>
int main ()
{
float a, b, c;
printf("Enter the value of a: ");
scanf("%f", &a);
printf("Enter the value of b: ");
scanf("%f", &b);
c =a/b;
printf("a divide b is = %f", c);
}
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page7
(4) (b) Write a program that divide two floating point
5) Write a program that read two integer and display reminder.
#include <stdio.h>
int main ()
{
int a, b, c;
printf("Enter the value of a: ");
scanf("%d", &a);
printf("Enter the value of b: ");
scanf("%d", &b);
c =a%b;
printf("Remainder = %d", c);
}
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page8
(6) (a) Write a program that read radius of a circle and display its area.
(6) (b) Write a program that read radius of a circle and display its area
#include <stdio.h>
void main ()
{
float r, area;
printf("Enter the radius : ");
scanf("%f", &r);
area = 3.1416*r*r;
printf("The area of the circle is: %f", area);
}
#include <stdio.h>
#define pi 3.1416
void main ()
{
float r, area;
printf("Enter the radius : ");
scanf("%f", &r);
area = pi*r*r;
printf("The area of the circle is: %f", area);
}
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page9
(6) (b) Write a program that read radius of a circle and display its area
(6) (c) Write a program that read radius of a circle and display its area
#include <stdio.h>
#define pi 3.1416
void main ()
{
float r, area;
printf("Enter the radius : ");
scanf("%f", &r);
area = pi*r*r;
printf("The area of the circle is: %f", area);
}
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
Page10
7) Write a program to demonstrate the working of increment and
decrement operators.
#include <stdio.h>
int main()
{
int a, c;
float b, d;
printf("a = ");
scanf("%d", &a);
printf("b = ");
scanf("%f", &b);
printf("c = ");
scanf("%d", &c);
printf("d = ");
scanf("%f", &d);
printf("++a = %d n", ++a);
printf("--b = %f n", --b);
printf("++c = %d n", ++c);
printf("--d = %f n", --d);
return 0;
}

More Related Content

What's hot (20)

Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]
 
Pslb lab manual
Pslb lab manualPslb lab manual
Pslb lab manual
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4
 
C- Programming Assignment 3
C- Programming Assignment 3C- Programming Assignment 3
C- Programming Assignment 3
 
Najmul
Najmul  Najmul
Najmul
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
 
C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year
 
Practical no 6
Practical no 6Practical no 6
Practical no 6
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
 
Cs8261 cp lab syllabus
Cs8261 cp lab syllabusCs8261 cp lab syllabus
Cs8261 cp lab syllabus
 
C- Programming Assignment practice set 2 solutions
C- Programming Assignment practice set 2 solutionsC- Programming Assignment practice set 2 solutions
C- Programming Assignment practice set 2 solutions
 
Practical no 1
Practical no 1Practical no 1
Practical no 1
 
Programming C Part 02
Programming C Part 02Programming C Part 02
Programming C Part 02
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
Programs that work in c and not in c
Programs that work in c and not in cPrograms that work in c and not in c
Programs that work in c and not in c
 
Practical no 3
Practical no 3Practical no 3
Practical no 3
 
Ankita sharma focp
Ankita sharma focpAnkita sharma focp
Ankita sharma focp
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
 
Prefix Postfix
Prefix PostfixPrefix Postfix
Prefix Postfix
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 

Viewers also liked

Origen y evolución de la corteza continental tfg cristina-agueraangel
Origen y evolución de la corteza continental tfg cristina-agueraangelOrigen y evolución de la corteza continental tfg cristina-agueraangel
Origen y evolución de la corteza continental tfg cristina-agueraangelMiguel Yepez
 
Cara membuat email di gmail
Cara membuat email di gmailCara membuat email di gmail
Cara membuat email di gmailfebryan15
 
Living things powerpoint
Living things powerpointLiving things powerpoint
Living things powerpointyellowfeather
 
пам'ятки архітектури та образотворчого мистецтва
пам'ятки архітектури та образотворчого мистецтвапам'ятки архітектури та образотворчого мистецтва
пам'ятки архітектури та образотворчого мистецтваsnizhanagur
 
Universal Count_ US & CA
Universal Count_ US  & CAUniversal Count_ US  & CA
Universal Count_ US & CAKurt Kozin
 
jay prakash_Resume
jay prakash_Resumejay prakash_Resume
jay prakash_Resumejay prakash
 
Covenin1756 2001-EDIFICACIONES SISMORRESISTENTES
Covenin1756 2001-EDIFICACIONES SISMORRESISTENTESCovenin1756 2001-EDIFICACIONES SISMORRESISTENTES
Covenin1756 2001-EDIFICACIONES SISMORRESISTENTESMiguel Yepez
 
Memasukkan file dari slide share ke blog
Memasukkan file dari slide share ke blogMemasukkan file dari slide share ke blog
Memasukkan file dari slide share ke blogfebryan15
 
ICICIdirect_PTC_Report
ICICIdirect_PTC_ReportICICIdirect_PTC_Report
ICICIdirect_PTC_ReportJitesh Bhanot
 
програма зно 2016
програма зно 2016програма зно 2016
програма зно 2016snizhanagur
 
Latihan point
Latihan pointLatihan point
Latihan pointfebryan15
 
Cede Profile Aug 2016
Cede Profile Aug 2016Cede Profile Aug 2016
Cede Profile Aug 2016Cede Prudente
 
Mario’s Love Life: An Epic Journey
Mario’s Love Life: An Epic JourneyMario’s Love Life: An Epic Journey
Mario’s Love Life: An Epic Journeyabel2600
 
Praktek point
Praktek pointPraktek point
Praktek pointfebryan15
 
Guía de supervisión de obras
Guía de supervisión de obrasGuía de supervisión de obras
Guía de supervisión de obrasMiguel Yepez
 
Monica Lorenzo Pugholm - mod større åbenhed i adoption
Monica Lorenzo Pugholm - mod større åbenhed i adoption Monica Lorenzo Pugholm - mod større åbenhed i adoption
Monica Lorenzo Pugholm - mod større åbenhed i adoption Monica Lorenzo Pugholm
 

Viewers also liked (20)

Origen y evolución de la corteza continental tfg cristina-agueraangel
Origen y evolución de la corteza continental tfg cristina-agueraangelOrigen y evolución de la corteza continental tfg cristina-agueraangel
Origen y evolución de la corteza continental tfg cristina-agueraangel
 
Cara membuat email di gmail
Cara membuat email di gmailCara membuat email di gmail
Cara membuat email di gmail
 
Living things powerpoint
Living things powerpointLiving things powerpoint
Living things powerpoint
 
Resume_nakri
Resume_nakriResume_nakri
Resume_nakri
 
FJMS
FJMSFJMS
FJMS
 
пам'ятки архітектури та образотворчого мистецтва
пам'ятки архітектури та образотворчого мистецтвапам'ятки архітектури та образотворчого мистецтва
пам'ятки архітектури та образотворчого мистецтва
 
Universal Count_ US & CA
Universal Count_ US  & CAUniversal Count_ US  & CA
Universal Count_ US & CA
 
jay prakash_Resume
jay prakash_Resumejay prakash_Resume
jay prakash_Resume
 
Covenin1756 2001-EDIFICACIONES SISMORRESISTENTES
Covenin1756 2001-EDIFICACIONES SISMORRESISTENTESCovenin1756 2001-EDIFICACIONES SISMORRESISTENTES
Covenin1756 2001-EDIFICACIONES SISMORRESISTENTES
 
Memasukkan file dari slide share ke blog
Memasukkan file dari slide share ke blogMemasukkan file dari slide share ke blog
Memasukkan file dari slide share ke blog
 
ICICIdirect_PTC_Report
ICICIdirect_PTC_ReportICICIdirect_PTC_Report
ICICIdirect_PTC_Report
 
програма зно 2016
програма зно 2016програма зно 2016
програма зно 2016
 
article 1
article 1article 1
article 1
 
Latihan point
Latihan pointLatihan point
Latihan point
 
Cede Profile Aug 2016
Cede Profile Aug 2016Cede Profile Aug 2016
Cede Profile Aug 2016
 
Mario’s Love Life: An Epic Journey
Mario’s Love Life: An Epic JourneyMario’s Love Life: An Epic Journey
Mario’s Love Life: An Epic Journey
 
Praktek point
Praktek pointPraktek point
Praktek point
 
Plus Size Lingerie
Plus Size LingeriePlus Size Lingerie
Plus Size Lingerie
 
Guía de supervisión de obras
Guía de supervisión de obrasGuía de supervisión de obras
Guía de supervisión de obras
 
Monica Lorenzo Pugholm - mod større åbenhed i adoption
Monica Lorenzo Pugholm - mod større åbenhed i adoption Monica Lorenzo Pugholm - mod større åbenhed i adoption
Monica Lorenzo Pugholm - mod større åbenhed i adoption
 

Similar to Arithmetic operator

Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentalsZaibi Gondal
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structuresPradipta Mishra
 
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHFC BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHFAbcdR5
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to cHattori Sidek
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programmingprogramming9
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures Pradipta Mishra
 
C programming language for beginners
C programming language for beginners C programming language for beginners
C programming language for beginners ShreyaSingh291866
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in cSaranya saran
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C ProgrammingShuvongkor Barman
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeksAashutoshChhedavi
 

Similar to Arithmetic operator (20)

Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
Programming in c
Programming in cProgramming in c
Programming in c
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
 
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHFC BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
C programming
C programmingC programming
C programming
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
Muzzammilrashid
MuzzammilrashidMuzzammilrashid
Muzzammilrashid
 
C programming language for beginners
C programming language for beginners C programming language for beginners
C programming language for beginners
 
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. AnsariBasic of C Programming | 2022 Updated | By Shamsul H. Ansari
Basic of C Programming | 2022 Updated | By Shamsul H. Ansari
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
C Programming
C ProgrammingC Programming
C Programming
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
C programming
C programmingC programming
C programming
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 

Recently uploaded

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 

Recently uploaded (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

Arithmetic operator

  • 1. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page1 Arithmetic Operator - Basic C Programming Solve Problems… 1. (a) Write a program that read two integer and display sum. (b) Write a program that read two floating point and display sum. 2. Write a program that subtracts two integer. 3. Write a program that read two integer and display product. 4. (a) Write a program that divide two integer. (b) Write a program that divide two floating point 5. Write a program that read two integer and display reminder. 6. Write a program that read radius of a circle and display its area. 7. Write a program to demonstrate the working of increment and decrement operators. SOLVED BY Md. Masudur Rahman Department of Textile Engineering 4th Batch National Institute of Textile Engineering and Research (NITER) masudbdasia@gmail.com
  • 2. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page2 Operator :Operators in C program is special symbol or word which directs the compiler to perform arithmetical or logical works, i.e. the characters which is used in C for special purpose so this character is called operators. Different types of operators :  Arithmetic operator  Unary operator  Relational operator  Logical operator  Assignment operator  Conditional operator Arithmetic Operators List : Arithmetic Operators niterians.blogspot.com Operator Meaning + Addition or unary plus - Subtraction or unary minus * Multiplication / Division % Modulo division ++ Increment operator increases the integer value by one. -- Decrement operator decreases the integer value by one.
  • 3. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page3 Arithmetic expressions: An arithmetic expression is a combination of variables, constants, and operators. For example, Arithmetic expressions: niterians.blogspot.com a*b-c a*b-c (m+n)(x+y) (m+n)*(x+y) ax2 +bx+c a*x*x+b*x+c 1) (a) Write a program that read two integer and display sum. #include <stdio.h> int main () { int a, b, c; printf("Enter the value of a : "); scanf("%d", &a); printf("Enter the value of b : "); scanf("%d", &b); c =a+b; printf("Sum of a and b is %d ", c); }
  • 4. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page4 (1) (b) Write a program that read two floating point and display sum. 2) Write a program that subtracts two integer. #include <stdio.h> int main () { float a, b, c; printf("Enter the value of a : "); scanf("%f", &a); printf("Enter the value of b : "); scanf("%f", &b); c =a+b; printf("Sum of a and b is %f ", c); } #include <stdio.h> int main () { int a, b, c; printf("Enter the value of a :"); scanf("%d", &a); printf("Enter the value of b :"); scanf("%d", &b); c =a-b; printf("a - b = %d", c); }
  • 5. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page5 2) Write a program that subtracts two integer 3) Write a program that read two integer and display product. #include <stdio.h> int main () { int a, b, c; printf("Enter the value of a : "); scanf("%d", &a); printf("Enter the value of b : "); scanf("%d", &b); c =a*b; printf("Product of a and b is %d ", c); }
  • 6. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page6 (4) (a) Write a program that divide two integer. (4) (b) Write a program that divide two floating point #include <stdio.h> int main () { int a, b, c; printf("Enter the value of a: "); scanf("%d", &a); printf("Enter the value of b: "); scanf("%d", &b); c =a/b; printf("a divide b is = %d", c); } #include <stdio.h> int main () { float a, b, c; printf("Enter the value of a: "); scanf("%f", &a); printf("Enter the value of b: "); scanf("%f", &b); c =a/b; printf("a divide b is = %f", c); }
  • 7. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page7 (4) (b) Write a program that divide two floating point 5) Write a program that read two integer and display reminder. #include <stdio.h> int main () { int a, b, c; printf("Enter the value of a: "); scanf("%d", &a); printf("Enter the value of b: "); scanf("%d", &b); c =a%b; printf("Remainder = %d", c); }
  • 8. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page8 (6) (a) Write a program that read radius of a circle and display its area. (6) (b) Write a program that read radius of a circle and display its area #include <stdio.h> void main () { float r, area; printf("Enter the radius : "); scanf("%f", &r); area = 3.1416*r*r; printf("The area of the circle is: %f", area); } #include <stdio.h> #define pi 3.1416 void main () { float r, area; printf("Enter the radius : "); scanf("%f", &r); area = pi*r*r; printf("The area of the circle is: %f", area); }
  • 9. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page9 (6) (b) Write a program that read radius of a circle and display its area (6) (c) Write a program that read radius of a circle and display its area #include <stdio.h> #define pi 3.1416 void main () { float r, area; printf("Enter the radius : "); scanf("%f", &r); area = pi*r*r; printf("The area of the circle is: %f", area); }
  • 10. Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com Page10 7) Write a program to demonstrate the working of increment and decrement operators. #include <stdio.h> int main() { int a, c; float b, d; printf("a = "); scanf("%d", &a); printf("b = "); scanf("%f", &b); printf("c = "); scanf("%d", &c); printf("d = "); scanf("%f", &d); printf("++a = %d n", ++a); printf("--b = %f n", --b); printf("++c = %d n", ++c); printf("--d = %f n", --d); return 0; }