1,373 views
2 votes
2 votes
int main()
{
   int a = 3, b = -8, c = 2;
   printf("%d", a % b / c);
   return 0;
}

2 Answers

0 votes
0 votes
"1" is right answer because if you find a modulo division with positive number with negative number then it always return a positive number as modulo division....
in your question ,a%b that means 3%(-8) it returns 3 however you try yourself by changing positive number it always give you same positive number( in the case of only single digit like 1,2,3,4...9) as remainder.
then ,after getting 3 as a remainder you have to divide it by 2,(3/2) it result as integer division and finally give 1 as output....
0 votes
0 votes
1)Precedance of modulo division is more,so a%b/c is equivalent to ((a%b)/c).

2)Modulo division as if 'Mod' word means always +ve.So a%b is always +ve.

So,a%b/c=((|a%b|)/b.int=3,b=-8,c=2.Hence,((|3%-8|)/2)=(3/2)=1.

Related questions

1 votes
1 votes
0 answers
1
Akshay Nair asked Jan 29, 2018
444 views
What is the output of the following program?void main(){printf("%d",5%2);printf("%d",-5%2);printf("%d",5%-2);printf("%d",-5%-2);printf("%d",2%5);}A) 1,-1 -1 1 0B)1 -1 1 -...
3 votes
3 votes
2 answers
2
Khushal Kumar asked Jul 10, 2017
1,578 views
#include <stdio.h>#include <string.h>void fun(char *arr){int i;unsigned int n = sizeof(arr);printf("n = %d\n", n);for (i=0; i<n; i++) printf("%c ", arr[i]);}// Driver pro...
2 votes
2 votes
2 answers
3
Khushal Kumar asked Jul 8, 2017
1,283 views
#include<stdio.h int main(void){ int a = 1, 2, 3; printf("%d", a); return 0;}
1 votes
1 votes
1 answer
4
Khushal Kumar asked Jul 7, 2017
342 views
#include <stdio.h>int main(){char a = '\'';printf("%c", a);return 0;}