if,int i=10,j=20,find s
while (i <=50)
{
i=i+10;
}
s=s+i+j;
System.out.println ("Sum="+s);
Answers
Answer:
s = 80
Explanation:
u will get an error because without initializing s u can't add it with i and j
in s = s+i+j , so
first of all u have to initialize int s = 0 because without that the program will not run.Take care that their are no spaces
the correct program is like this :
public class s
{
public static void main(String []args)
{
int i=10,j=20,s=0;
while (i <=50)
{
i=i+10;
}
s=s+i+j;
System.out.println("Sum="+s);
}
}
and then it will compile and when we will run it it will the output as:
sum = 80
Hope it helps!
plz mark me as brainliest if it helps you!
Question:-
Write the output of the following code.
Solution:-
Given code,
int i=10,j=20,s;
while (i <=50)
{
i=i+10;
}
s=s+i+j;
System.out.println ("Sum="+s);
After completion of loop, the value of i will be,
60
s=0+60+20=80
Now, s gets printed.
Output:-
80