• Write a program in Cpp to check whether a number is even or odd:

    Write a program to check whether a number is even or odd:

    1. For even number we check the reminder if reminder is equal to zero so the given number is even otherwise odd.
    2. For reminder in c++ we use modulus operator (%). 
              Coding:

             #include <iostream>

             using namespace std;

            int main(){

                  int x;

        cout<<"Enter a number: "<<endl;

        cin>>x;

        if(x%2==0){

            cout<<"This is even number: "<<endl;

        }

        else{

            cout<<"This is odd number: "<<endl;

        }


    return 0;

     }

  • 0 comments:

    Post a Comment

    GET A FREE QUOTE NOW

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

    Search This Blog

    Powered by Blogger.

    Blog Archive

    ADDRESS

    Peshawar Pakistan

    EMAIL

    hk2456632@mail.com

    WhatsApp Number

    +92 3335590608