(This is for Java)
For this I need to make a loop that will sum the numbers from 3 to 22
public class Practice25 {
public static void main (String [] args) {
int sum = 0;
//The loop will go here
sum += i;
System.out.println ("Sum from 3 to 22 is: " +
sum);
}
}
Java code:
public class Practice25{
public static void main (String [] args) {
//initializing sum
int sum=0;
//looping from 3 to 22
for(int i=3;i<=22;i++)
//adding it to sum
sum+=i;
//printing sum
System.out.println("Sum from 3 to 22 is: "+sum);
}
}
Screenshot:
Output:
Get Answers For Free
Most questions answered within 1 hours.