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
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
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.
* Assignment operator
* Conditional operator
* Arithmetic Operators List :
* Arithmetic expressions:
An arithmetic expression is a combination of variables, constants, and operators.
For example,
(1) (b) Write a program that read two floating point and display sum.
2) Write a program that subtracts two integer.
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.
(4) (b) Write a program that divide two floating point
(4) (b) Write a program that divide two floating point
5) Write a program that read two integer and display reminder.
(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
(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
7) Write a program to demonstrate the working of increment and decrement operators.
Arithmetic Operator - Basic C Programming Solve niterians.blogspot.com
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;
}