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.
#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 :
1.
Arithmetic operator
2.
Unary operator
3.
Relational operator
4.
Logical operator
5.
Assignment operator
6.
Conditional operator
#Arithmetic Operators List :
# Arithmetic
expressions:
Problems…
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);
}
(1)(b) Write a program that read two
floating point and display sum.
#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);
}
2) Write a program that subtracts two integer.
#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);
}
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);
}
(4) (a) Write a program that
divide two integer.
#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);
}
(4) (b) Write a program that
divide two floating point.
#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);
}
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);
}
(6) (a) 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);
}
(6) (b) 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);
}
(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);
}
Posted By:
Md. Zamil Mia
Campus Correspondent
Shyamoli Textile Engineering College
Arithmetic Operator - Basic C Programming Solve
Reviewed by Zamil
on
6:02 PM
Rating:
No comments: