Thread: Examples for and, or , not statements

  1. #1
    shaiju jose
    Guest

    Examples for and, or , not statements

    Hi,

    There is no examples of and, or, and not statements in our tutorials. Can i get some sample codings of and, or, and not.

    thanks in advance

    beginner and C++ lover

    shaiju jose

  2. #2
    Still A Registered User DISGUISED's Avatar
    Join Date
    Aug 2001
    Posts
    499
    Is this what your asking for?

    Code:
     
    #include <iostream> 
    using namespace std; 
    int main() 
    {
        int var_0 = 0, //0 is false  
            var_1 = 1, //1 is true 
            var_2 = 2, 
            var_3 = 3; 
        {
            cout<<"\nTHE BASICS\n"; 
            if(!var_0) 
               cout<<"\nThis prints because the if statement "
    	      <<"asks is var_0 false? Which is true because "
    	      <<"var_0 is equal to zero"
    	      <<endl; 
    
            if(var_1) 
               cout<<"\nThis prints because the if statement " 
    	      <<"asks is var_1 true? Which is also true "
    	      <<"becasue var_1 is equal to one"
    	      <<endl; 
          
            if(var_2 == 2 && var_3 == 3) 
    	  cout<<"\nThis prints because the if statement " 
    	      <<"asks is var_2 equal to 2 AND is var_3 " 
       	      <<"equal to three? Which is also true"
    	      <<endl; 
          
            if(var_2 == 2 || var_3 == 5) 
    	  cout<<"\nThis prints because the if statement " 
    	      <<"asks is var_2 equal to 2 OR is var_3 equal " 
    	      <<"to 5? Which is also true because var_2 is " 
    	      <<"equal to 2"
    	      <<endl; 
    		
            if(var_2 == var_3)
    	  cout<<"\nThis will not print because these two " 
    	      <<"variables are not equal"
    	      <<endl; 	
        }
        return 0; 
    }
    Last edited by DISGUISED; 06-11-2002 at 10:28 PM.

Popular pages Recent additions subscribe to a feed