Friday, August 23, 2013

Logical Operators

Example 1:
//Logical operators in C
#include <stdio.h>
int main()
{
   int a,b,c;
   printf("Enter the values of a,b, and c\n");
   scanf("%d %d %d", &a, &b, &c);
   if((a > b) && (a > c))
   printf("a is greatest \n");
   else if(b > c)
   printf("b is greatest \n");
   else
   printf("c is greatest \n");
   if((a == 0) || (b == 0) || (c == 0))
   printf("The product of a, b and c is zero \n");
   return 0;
}

//Video Tutorial





Example 2:

//Logical operators in C++
#include <iostream>
using namespace std;
int main()
{
   int a,b,c;
   cout <<"Enter the values of a,b, and c\n";
   cin >>a >>b >>c;
   if((a > b) && (a > c))
   cout <<"a is greatest \n";
   else if(b > c)
   cout <<"b is greatest \n";
   else
   cout <<"c is greatest \n";
   if((a == 0) || (b == 0) || (c == 0))
   cout <<"The product of a, b and c is zero \n";
   return 0;
}

2 comments:

  1. its coding is so simple and understandable

    ReplyDelete
  2. good afternoon sir....this concept is define simple way. I hope this website is learn more and more person

    ReplyDelete