CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2013
    Posts
    2

    Simple modulus problem...

    I'm working on a program to calculate what day Easter falls on, but I'm getting garbage as answers. So I've been trying to isolate the problem working on one of my statements finding the remainder.
    Here's what I have.

    int year, a;
    a = year % 19;
    cout << "Enter Year: ":
    cin >> year;

    cout << a;

    When I enter 2013 for my year, my output is 16 when it should be 18....What am I doing wrong?

  2. #2
    Join Date
    Feb 2013
    Posts
    2

    Re: Simple modulus problem...

    Nvm, I have solved the problem...I needed to put the a= year % 19; statement after cin >> year;

  3. #3
    Join Date
    May 2009
    Posts
    2,413

    Re: Simple modulus problem...

    It's a good example of the causality principle. Cause precedes effect.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured