i need to understand the meaning of sum 1 =sum2 =0 and if(1%2 = = 0)
{ int sum1, sum2; sum1 = sum2 = 0; for ( int i =1 ; i < = 10 ; i++) if (1 % 2 = = 0) sum1+ = i ; else sum2+ = i ; please make me understand the meaning of line line 2 and line 4 question is to write a programme that wil calculate sum of even numbers 1 to 10
line 2: sum1=sum2=0; (first assignment)
i think it's wrong it should be like this { int sum1, sum2; sum1 = sum2 = 0; for ( int i =1 ; i < = 10 ; i++) if (i % 2 = = 0) sum1+ = i ; else sum2+ = i ;
you can retype as sum1=0; sum2=0;
u r rite amir ,dnt wrry abt spaces and those, why sum1=sum2=o is written and wats the maning of i%2= = 0
sum1 will show you the sum of even number and the sum 2 will show the sum of odd number between 1to 10
i hv started studyn c++ today so im a kid in this
if i is odd then i%2==0 .....i=0 (mod2)..........
no i think if i is even then i%2 == 0
tahat means 'i divided by 2 equal to zero'
oh yes that must be even
mainly im not the point that why sum1=0 and sum2=0 is written WHYYY WEQUAL TO 0
what
in programming = sign is assignment sign
== means equal
yessss exaccly and dnt knw/rember all the signs.... so please explain in this way
and why it was necessary to define that IF I DEVIDED BY 2 its 0
and once again i%2==0 means ''i divided by 2 is equal to 0''
whats the need of this setence here pleae explain
sorry sorry the remainder is qqual to 0 (i am so sorry.Dont wanted to confuse u)
yesssss I was confused that slash / is for deviding not % GOT IT !!!!!! THANK U SSSOOOO MUCHHH!!!!
my english is not that good. so i cannot explain that good.
Join our real-time social learning platform and learn together with your friends!