Program to illustrate If-else statement

/* : The If-else statement - find minimum number */
    #include <iostream.h>
    void main()
    {
        int x , y , min ;
        cout<<"Enter any two numbers : ";
        cin>>x>>y ;

        if (x<y)
        cout<<"The minimum number is "<<x ;
        else
        cout<<"The minimum number is "<<y ;
    }

-------------------------------------------


/* Program: The If-else statement - Even or Odd number */
    #include <iostream.h>
    void main()
    {
        int a , temp ;

        cout<<"Enter a number : " ;
        cin>>a ;
        temp = a % 2 ;
        if (temp == 0)
        cout<<"The number is Even." ;
        else
        cout<<"The number is Odd.";
    }
-------------------------------------------------------

/* Program: The If-else statement-find whether divisible by 3*/
    #include <iostream.h>
    void main()
    {
        int x , temp ;
        cout<<"Enter a number : " ;
        cin>>x ;
        temp = x % 3 ;
        if (temp == 0) ;
        else
            cout<<"The number is not divisible by 3" ;
    }


1 comments:

yavuz said...

kırşehir
karabük
adıyaman
niğde
ordu
VHTR

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|