Saturday, August 11, 2018

Logical Operators in C++

A very simple program using C++ to show how to use logical operators.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work, computer tutorials and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Sample Program Output


logical.cpp


#include <iostream>

using namespace std;

int main()
{
    int a=10, b=4, c = 10, d = 20;
 
    // logical operators
 
    // logical AND example
    cout <<"\n\n";
   
    if (a>b && c==d) {
     cout <<"\tA is greater than B AND C is equal to D.\n";
    }
    else {
   cout <<"\tAND condition not satisfied.\n";
   }
   
    // logical AND example
    if (a>b || c==d) {
cout <<"\tA is greater than B OR C is equal to D.\n";
       }
    else 
{
cout <<"\tNeither A is greater than B nor C is equal to D.\n";
    }
    // logical NOT example
    if (!a) {
        cout <<"\tA is zero.\n";
    }
    else {
    cout <<"\tA is not zero.";
  }
cout <<"\n\n";
    return 0;
}

No comments:

Post a Comment