Discussion topic: Contributed Answer/Explanation to Q. 13
To go to the homepage of this topic,
click here.
Home: hayabusa | Original Message | Reply | Subject: Contributed Answer/Explanation to Q. 22 | class sum
Posted at: Mon Jan 31 12:00:26 2011 (GMT) |
Page 1 of 1 | From: hayabusa | Reply 1 of 1 | Reply | | Subject: Contributed Answer/Explanation to Q. 22 | program
class sum{public static void main(int n){even=0,odd=0;for(int
i=1;i<=n;i++){if(i%2==0)even=even+i;elseodd=odd+i; } System.out.println
("sum of even="+even) ;System.out.println("sum of
odd="+odd); } } Posted at: Mon Jan 31 12:10:36 2011 (GMT)
|
Page 1 of 1
|
|
To post to this forum, you must be signed in as a Syvum member.
Please sign in / register as a member.