Computer Science, asked by starchase, 8 months ago

Predict the output of the following program segments:
1)
public class Natural
{
public static void main(String args[])
{
int a,s;
S=0;for(a=1;a<10;a++)
{
s=s+a;
}
System.out.println(“The sum of numbers is “+s);
}
}

Answers

Answered by Oreki
1

Output:

45

Explanation:

1 + 2 + 3 + ... + 8 + 9 = 45

Answered by nishadhani7
0

I excuse you for rest of your life.....

Attachments:
Similar questions