need a cooment for looping

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • noobc++

    need a cooment for looping

    i have a problem in displaying the even value. i try to do the exercise
    in asking the user of the value of x and the value of y. then, showing
    the value bettween x and y. in between the value x and y there suppose
    to be an even and odd number.
    for exampe if the value x = 1 and the value of y = 5. then it will
    write 12345. (i done this). but, i have the problem in showing the even
    value between x and y . i use for loops for showing the 12345 and then
    i confused for showing the even value. i know the formula would be
    value*2..

  • lw1a2

    #2
    Re: need a cooment for looping

    #include <iostream>
    using namespace std;

    void foo(int low, int high)
    {
    for (int i=low; i<=high; ++i)
    if ((i%2)==0) cout<<i;
    cout<<endl;
    }

    int main()
    {
    foo(1, 5);
    system("pause") ;
    return 0;
    }

    Comment

    • noobc++

      #3
      Re: need a cooment for looping

      thank you
      lw1a2 wrote:
      #include <iostream>
      using namespace std;
      >
      void foo(int low, int high)
      {
      for (int i=low; i<=high; ++i)
      if ((i%2)==0) cout<<i;
      cout<<endl;
      }
      >
      int main()
      {
      foo(1, 5);
      system("pause") ;
      return 0;
      }

      Comment

      • noobc++

        #4
        Re: need a cooment for looping

        thank's
        lw1a2 wrote:
        #include <iostream>
        using namespace std;
        >
        void foo(int low, int high)
        {
        for (int i=low; i<=high; ++i)
        if ((i%2)==0) cout<<i;
        cout<<endl;
        }
        >
        int main()
        {
        foo(1, 5);
        system("pause") ;
        return 0;
        }

        Comment

        • Howard

          #5
          Re: need a cooment for looping


          "lw1a2" <lw1a2.JING@gma il.comwrote in message
          news:1159604415 .217831.172560@ k70g2000cwa.goo glegroups.com.. .
          #include <iostream>
          using namespace std;
          >
          void foo(int low, int high)
          {
          for (int i=low; i<=high; ++i)
          if ((i%2)==0) cout<<i;
          cout<<endl;
          }
          >
          int main()
          {
          foo(1, 5);
          system("pause") ;
          return 0;
          }
          >
          How about not just doing others' homework for them, eh? How's he supposed
          to learn anything if all his answers are simply handed to him? Do you want
          to work with some idiot who passed his courses simply by asking others to do
          their work?

          -Howard



          Comment

          Working...