Operator for

Enter the numbers a and b. Find how many numbers in the interval (a; b] when divided by 7 gives the remainder of 4. The result is displayed on the screen. Also, to display themselves such numbers.
How to solve this?
If you have a number in an integer like int a; then you can display it with cout << a << '\n'; This will print a and then a the "new line" character to advance to the next line.


To figure out the numbers you'll need a little math. I suggest you try to work out how to do it with pencil and paper first. Then you can figure how to translate that into code.
I need to use opereator for,for this task
Any example,how to write this code?
Last edited on
Use a for loop to loop over the interval [a, b).
http://www.cplusplus.com/doc/tutorial/control/#for
unsigned int number;
for(unsigned int i=a+1;i>a&&i==b;i++) /// number ; interval ; increment the number after the last loop initiated
{
///supposing all are integers, since if you render them to decimal there would be a tendency of infinity of interval sets

///you know your logic here
when divided by 7 gives the remainder of 4.


number = i;

///if you want, you can display the numbers here too...just use an array or a set

}

std::cout<<number;

that's some way on how to make it's frame; You need to find the body/logic, that's what we do as programmers. :)

see reference http://www.cplusplus.com/reference/ for more info about the terms and usage.
Last edited on
Topic archived. No new replies allowed.