Question about notation

I know what %c is if c is a character, but can someone explain me what c%7 == 0 means? Thanks
% calculates the remainder, "%c" is used by C functions when parsing strings
Thanks. So if it calculates the remainder is it that c (even though its char) divided by 7 gives the remainder 0?
Don't forget that chars still are (integer) numbers, so remainder is still a valid operation. Check an ascii table to see their exact values.

Last edited on
So if it calculates the remainder is it that c (even though its char) divided by 7 gives the remainder 0?

In this expression, c%7 == 0 there is nothing to indicate what c is, we can infer from the context that it is some sort of integer type, but it need not be a character. It could just as well be an int.

It takes the integer variable c, finds the remainder when dividing by 7. Then it tests whether that remainder is equal to zero.

Example (using C++)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>

using namespace std;

int main()
{

    for (int c=0; c<50; ++c)
    {        
        if (c%7 == 0)
        {
            cout << c << " is a multiple of 7\n";
        }
            
    }
}
0 is a multiple of 7
7 is a multiple of 7
14 is a multiple of 7
21 is a multiple of 7
28 is a multiple of 7
35 is a multiple of 7
42 is a multiple of 7
49 is a multiple of 7

c (even though its char)


He said it's a char. Or maybe he's assuming it's a char? Hard to tell without a snippet.
Last edited on
Thank you very much guys!
Topic archived. No new replies allowed.