C++

This is a discussion on C++ within the C++ Programming forums, part of the General Programming Boards category; I am a beginner learning C++; I having problems with my first program and I need some help. How do ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    1

    Post C++

    I am a beginner learning C++; I having problems with my first program and I need some help. How do I write a program that determines odd, even and mixed sets of number using modulus (%)?

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    4
    modulus is integer division, getting the integer quotient and remainder. Dividing an integer by an even number the remainder will be 0, thus if num%2 == 0 the variable num must be even the rest you should be able to figure out.

  3. #3
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    # inlcude <iostream.h>
    # include <conio.h>

    main()
    {

    int a,b;
    cout<<" Enter a number ";
    cin>>a;
    b=a%2;
    if(b==0)
    cout<<" Even number";
    else
    cout<<" Odd number ";


    }

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21