0

Print(2*5-2%1) what to do first? Tell me whole process.

8th Jul 2021, 8:16 AM
URThePro
URThePro - avatar
7 Antworten
+ 5
first we have will see which operators have high precedence In the question, (*,%) has high precedence than (-) (*,%) has equal to precedence so we will use it associativity rule i.e. left to right so the operator from (*,%) will be solved first that is one the left side We will solve it like this- (2*5-2%1) (10-2%1) * is on the left side so it got first solved before % (10-0) % has more precedence than - 10 10 is the final answer Hope you got understand........
8th Jul 2021, 8:40 AM
Mayank Dhull
Mayank Dhull - avatar
+ 7
It is actually following the rule of BODMAS... Brackets Orders Division Multiplication Addition Subtraction Here Print(2*5-2%1) has no bracket so passes to division method i.e. 2%1 = 0 then multiplication 2*5 = 10 then at last substraction of 10-0 which is 10 ....so it will print 10...
9th Jul 2021, 10:56 AM
Pallavi Bhardwaj
Pallavi Bhardwaj - avatar
+ 7
Ben sidhom Akram Bro firstly division is done then multiplication.....
10th Jul 2021, 11:10 AM
Pallavi Bhardwaj
Pallavi Bhardwaj - avatar
+ 2
1. 2*5=10 2. 2%1=0 3. 10-0=10
8th Jul 2021, 8:37 AM
Qasem
+ 2
* and % have the same precedence and their precedence is higher than that of - Therefore this is evaluated as follows, (2*5)-(2%1) which gives 10.
8th Jul 2021, 8:38 AM
Kirabo Ibrahim
Kirabo Ibrahim - avatar
+ 2
Thanx to all.
8th Jul 2021, 8:39 AM
URThePro
URThePro - avatar
- 1
Firstly , do the multiplication of 2*5=>10 Secondly , do the modulo of 2%1=>0 Finally do the subtraction =>10-0=10
10th Jul 2021, 6:06 AM
Ben sidhom Akram