Hi Robert
This may help u
[code=java]
public class Add {
public static void main(String[] args) {
long sum = 0;
for (int i=1; i<=1000; i++) {
if(i==300 || i==500){
}
else{
sum = (sum + i);
}
}
System.out.prin tln("Sum of number 1 to 1000 excluding 300 and 500 is: " + sum);
...
User Profile
Collapse
-
-
Sorry by mistake i sent it to u, its for the user who asked the question....Leave a comment:
-
It will never print the * as u expecting....
fot int i=1 , it will never print *, for i=2 it starts printing but not in the format as u said.....
its a loop ranging from -ve values to +ve values for intgerers for 32 bit size machine.
the logic is wrong......Leave a comment:
-
-
No activity results to display
Show More
Leave a comment: