SlideShare a Scribd company logo
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

Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]Lab manualsahu[et&amp;t]
Lab manualsahu[et&amp;t]
Vivek Kumar Sinha
 
Pslb lab manual
Pslb lab manualPslb lab manual
Pslb lab manual
Vivek Kumar Sinha
 
Testing lecture after lec 4
Testing lecture after lec 4Testing lecture after lec 4
Testing lecture after lec 4emailharmeet
 
C- Programming Assignment 3
C- Programming Assignment 3C- Programming Assignment 3
C- Programming Assignment 3
Animesh Chaturvedi
 
Najmul
Najmul  Najmul
Najmul
Najmul Ashik
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
Animesh Chaturvedi
 
C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year
mohdshanu
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
Mansi Tyagi
 
Cs8261 cp lab syllabus
Cs8261 cp lab syllabusCs8261 cp lab syllabus
Cs8261 cp lab syllabus
Palani Chamy
 
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
Animesh Chaturvedi
 
Programming C Part 02
Programming C Part 02Programming C Part 02
Programming C Part 02
Raselmondalmehedi
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
Prasadu Peddi
 
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
Ajay Chimmani
 
Ankita sharma focp
Ankita sharma focpAnkita sharma focp
Ankita sharma focp
AnkitaSharma463389
 
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
Rumman Ansari
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
Padma Kannan
 

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-agueraangel
Miguel Yepez
 
Cara membuat email di gmail
Cara membuat email di gmailCara membuat email di gmail
Cara membuat email di gmail
febryan15
 
Living things powerpoint
Living things powerpointLiving things powerpoint
Living things powerpoint
yellowfeather
 
пам'ятки архітектури та образотворчого мистецтва
пам'ятки архітектури та образотворчого мистецтвапам'ятки архітектури та образотворчого мистецтва
пам'ятки архітектури та образотворчого мистецтва
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 SISMORRESISTENTES
Miguel 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 blog
febryan15
 
ICICIdirect_PTC_Report
ICICIdirect_PTC_ReportICICIdirect_PTC_Report
ICICIdirect_PTC_ReportJitesh Bhanot
 
програма зно 2016
програма зно 2016програма зно 2016
програма зно 2016
snizhanagur
 
Latihan point
Latihan pointLatihan point
Latihan point
febryan15
 
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 Journey
abel2600
 
Praktek point
Praktek pointPraktek point
Praktek point
febryan15
 
Plus Size Lingerie
Plus Size LingeriePlus Size Lingerie
Plus Size Lingerie
saucyladiesintimates745
 
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
Miguel 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

Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
Mehul Desai
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
Zaibi Gondal
 
Programming in c
Programming in cProgramming in c
Programming in c
Ashutosh Srivasatava
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
gamingwithfaulty
 
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
Pradipta 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[DSSIFLHDSHF
AbcdR5
 
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 Programming
programming9
 
C programming
C programmingC programming
C programming
Shahariar limon
 
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
 
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
G. H. Raisoni Academy of Engineering & Technology, Nagpur
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
JavvajiVenkat
 
C Programming
C ProgrammingC Programming
C Programming
Raj vardhan
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
Saranya saran
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
Shuvongkor Barman
 
C programming
C programmingC programming
C programming
Rounak Samdadia
 
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
imtiazalijoono
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 

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

Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 

Recently uploaded (20)

Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 

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; }