What is the output of the code written in C? void main()
What is the output of the code written in C?
void main()
{
printf("%d", 7%-3);
printf("%d", -7%3);
}
Show answerHide answer
Correct answer: (A) 1 −1
Explanation
In C the result of % takes the sign of the dividend: 7 % −3 = 1 and −7 % 3 = −1. The two printf calls print 1 and −1.