Tuesday, July 22, 2014

Using For Loop while using Mathematical Operations in Java

public class abejeroact18 {
public static void main(String[] jda) {
int a;
int b = 0;
for (a=1;a<=50;a++)
{
System.out.println(a);
b=b+a;
}
System.out.println("The Number on the Right is the Sum\n" +"of the First 50 Natural Numbers\t" +b);
}
}

No comments:

Post a Comment