Ask your own question, for FREE!
Mathematics 12 Online
OpenStudy (anonymous):

i need to understand the meaning of sum 1 =sum2 =0 and if(1%2 = = 0)

OpenStudy (anonymous):

{ 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

OpenStudy (anonymous):

line 2: sum1=sum2=0; (first assignment)

OpenStudy (anonymous):

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 ;

OpenStudy (anonymous):

you can retype as sum1=0; sum2=0;

OpenStudy (anonymous):

u r rite amir ,dnt wrry abt spaces and those, why sum1=sum2=o is written and wats the maning of i%2= = 0

OpenStudy (anonymous):

sum1 will show you the sum of even number and the sum 2 will show the sum of odd number between 1to 10

OpenStudy (anonymous):

i hv started studyn c++ today so im a kid in this

OpenStudy (anonymous):

if i is odd then i%2==0 .....i=0 (mod2)..........

OpenStudy (anonymous):

no i think if i is even then i%2 == 0

OpenStudy (anonymous):

tahat means 'i divided by 2 equal to zero'

OpenStudy (anonymous):

oh yes that must be even

OpenStudy (anonymous):

mainly im not the point that why sum1=0 and sum2=0 is written WHYYY WEQUAL TO 0

OpenStudy (anonymous):

what

OpenStudy (anonymous):

in programming = sign is assignment sign

OpenStudy (anonymous):

== means equal

OpenStudy (anonymous):

yessss exaccly and dnt knw/rember all the signs.... so please explain in this way

OpenStudy (anonymous):

and why it was necessary to define that IF I DEVIDED BY 2 its 0

OpenStudy (anonymous):

and once again i%2==0 means ''i divided by 2 is equal to 0''

OpenStudy (anonymous):

whats the need of this setence here pleae explain

OpenStudy (anonymous):

sorry sorry the remainder is qqual to 0 (i am so sorry.Dont wanted to confuse u)

OpenStudy (anonymous):

yesssss I was confused that slash / is for deviding not % GOT IT !!!!!! THANK U SSSOOOO MUCHHH!!!!

OpenStudy (anonymous):

my english is not that good. so i cannot explain that good.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!