In C language,% can only be used as an operator for integer operations, and% is a remainder operator, which can only be used for integer and integer operations. If it is used for non-integer operations, the program will report an error and cannot run.
option a is wrong, because in c language, sentences are divided by semicolons in English, that is, ";" , not a colon.
the d option is correct because% is a division and remainder operation, which is suitable for integer and integer operations. Otherwise, different compilers will get different results. As binocular operators, the left and right operands can be numeric values or expressions, but the left and right operands must be integers.
Extended data
The remainder operator "%"is a binary operator, which is left associative. The quantities involved in the operation are all integers. The result of the remainder operation is equal to the remainder after the division of two numbers. The "%"modulo operator has some small applications, such as:
1. When you want to get a random number through rand (), rand ()% 1; Generate a random number of -99.
if you want to generate a number between 16 and 59, you can write it like this: rand()%44+16 (where 44 is obtained from 59-16+1).
rand()%44 can get the random number of -43, and add 16 to get the random number of 16-59;
2. The "%"operation is also commonly used for N-ary conversion.
if it is binary conversion, you can use/with% to get the converted binary number (actually short division). When the original number is divided to the remaining , the last modulus of the original number is the highest decimal number.
Baidu encyclopedia-operator