in Programming in C
393 views
2 votes
2 votes

in Programming in C
by
393 views

2 Comments

Never encountered such question except 3rd answer all seems to be logical error
0
0
Can u explain a bit !!
0
0

2 Answers

2 votes
2 votes
option 1) % has highest precedence then + associative left to right

-13%-5+3 ..( a mod b = a-(b*(a/b))) = $-13-(-5*\frac{13}{5})$ =$-13-(-5*2)$

-3+3

0

2) 3/-3/3 from 1 (-13%-5=-2)

-1/3

-0.3333...

3)  -5%3/13

$\frac{1}{13}$

4) 4/(-10 % -2) /3   $-10-(-2*\frac{-10}{-2})$ =$-10-(-2*5)$

4/0/3 DIVISION BY ZERO ERROR

1 comment

small correction :  -5 % 3 is -2 so, it is -2/13

0
0
0 votes
0 votes
last one..according to precedence % will be calculated first and then divide,so its 4/0 which is a logical error.

1 comment

But,the question is asking logical error.And division by zero is a run time error and not a logical error.

@Tesla! can you please give the source of this a mod b formula ? Not understood clearly.
0
0

Related questions

0 votes
0 votes
1 answer
1
VS asked in Quantitative Aptitude Apr 9, 2017
364 views
VS asked in Quantitative Aptitude Apr 9, 2017
by VS
364 views
0 votes
0 votes
2 answers
2
VS asked in Verbal Aptitude Apr 9, 2017
289 views
VS asked in Verbal Aptitude Apr 9, 2017
by VS
289 views
0 votes
0 votes
2 answers
3
VS asked in Quantitative Aptitude Apr 9, 2017
450 views
VS asked in Quantitative Aptitude Apr 9, 2017
by VS
450 views
0 votes
0 votes
3 answers
4
VS asked in Quantitative Aptitude Apr 9, 2017
456 views
VS asked in Quantitative Aptitude Apr 9, 2017
by VS
456 views