Write a program to perform all the relational operations on two variables of float type.
Answers
Explanation:
In this Intensive C++ Training Series, we learned about the various concepts in C++ like variables, storage classes, type qualifiers, etc in our earlier tutorials. We also came to know how we can modify these variables.
To do these modifications, we need to perform operations on these variables & constants and to perform these operations we make use of operators.
Operators are symbols which act on variables or other entities that are called operands and perform mathematical or logical operations to modify their values and produce results accordingly.
The following program demonstrates floating point arithmetic in action.
#include<stdio.h>
int main()
{
// Declare and initialize variable a and b
double a = 9.2, b = 2.1;
printf("a + b = %f\n", a + b);
printf("a - b = %f\n", a - b);
printf("a * b = %f\n", a * b);
printf("a / b = %f\n", a / b);
// Signal to operating system everything works fine
return 0;
}