Header Files and Operators in C++

 //1. System header files : It comes with the compiler

#include<iostream>
using namespace std;
//  There are two types of header files :
//1. System header files : It comes with the compiler
//2. User defined header files : It is written by the programmer
//  #include "this.h" --> This will produce an error if this.h is not present
// in the current directory.

int main()
{
    int a = 4, b = 5, c = 123, d = 40;
    cout<<"Hello World\n";
    cout<<"Operators in C++ :"<<endl;
    cout<<"Following are the types of operators in C++"<<endl;
    //  Arithmetic operators
    cout<<"The value of a + b is "<<a+b<<"\n";
    cout<<"The value of a - b is "<<a-b<<endl;
    cout<<"The value of a * b is "<<a*b<<"\n";
    cout<<"The value of a / b is "<<a/b<<endl;
    cout<<"The value of a % b is "<<a%b<<endl;
    cout<<"The value of c % d is "<<c%d<<endl;
    cout<<"The value of a++ is "<<a++<<endl;
    cout<<"The value of b++ is "<<b++<<endl;
    cout<<"The value of a-- is "<<a--<<endl;
    cout<<"The value of b-- is "<<b--<<endl;
    cout<<"The value of ++a is "<<++a<<endl;
    cout<<"The value of ++b is "<<++b<<endl;
    cout<<"The value of --a is "<<--a<<endl;
    cout<<"The value of --b is "<<--b<<endl;
    cout<<endl;

    // Assignment Operators --> used to assign values to variables
    int e = 3, f = 5;
    char i = 'r';

    //  Comparison Operators
    cout<<"Following are the comparison Operatos in C++"<<endl;
    cout<<"The value of a == b is "<<(a==b)<<endl;
    cout<<"The value of a != b is "<<(a!=b)<<endl;
    cout<<"The value of a >= b is "<<(a>=b)<<endl;
    cout<<"The value of a <= b is "<<(a<=b)<<endl;
    cout<<"The value of a > b is "<<(a>b)<<endl;
    cout<<"The value of a < b is "<<(a<b)<<endl;
    cout<<endl;

    //  Logical Operators
    cout<<"Following are the Logical Operatos in C++"<<endl;
    cout<<"The value of ((a==b) && (a<b)) logical AND operator is "<<((a==b) && (a<b))<<endl;
    cout<<"The value of ((a==b) || (a<b)) logical OR operator is "<<((a==b) || (a<b))<<endl;
    cout<<"The value of (!(a==b)) logical NOT operator is "<<(!(a==b))<<endl;

    return 0;
}
//OUTPUT:
// Hello World
// Operators in C++ :
// Following are the types of operators in C++
// The value of a + b is 9
// The value of a - b is -1
// The value of a * b is 20
// The value of a / b is 0
// The value of a % b is 4
// The value of c % d is 3
// The value of a++ is 4
// The value of b++ is 5
// The value of a-- is 5
// The value of b-- is 6
// The value of ++a is 5
// The value of ++b is 6
// The value of --a is 4
// The value of --b is 5

// Following are the comparison Operatos in C++
// The value of a == b is 0
// The value of a != b is 1
// The value of a >= b is 0
// The value of a <= b is 1
// The value of a > b is 0
// The value of a < b is 1

// Following are the Logical Operatos in C++
// The value of ((a==b) && (a<b)) logical AND operator is 0
// The value of ((a==b) || (a<b)) logical OR operator is 1
// The value of (!(a==b)) logical NOT operator is 1

Comments

Popular posts from this blog

Control Structures, If Else and Switch Case Statements in C++

Basic Input/Output & More in C++