0

While in java

Why Only 1 test passed out of 4 public int whileExample (int end){ int sum = 0; int i = 0; while (i < 6){ sum = sum + i; i = i + 1; } return sum; }

14th May 2023, 3:37 PM
Olga Restea
7 odpowiedzi
+ 2
What is the your task here? Share total code with full description..
14th May 2023, 3:56 PM
Jayakrishna 🇮🇳
+ 2
Don't share your code in description and attach the relevant programming tag also
14th May 2023, 4:13 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 2
Yes. It will return 15 But what does the passing parameter 'end' do there? May be you are taking count 0 to 6 , but i think you need to take care about 'end' value. Read description carefully again
14th May 2023, 4:30 PM
Jayakrishna 🇮🇳
+ 1
I need to find sum of numbers 0 to 6 (6 excluded). Answer should be 15.
14th May 2023, 4:19 PM
Olga Restea
+ 1
i <end , end is 6
14th May 2023, 4:36 PM
Olga Restea
+ 1
Thank you, I got it.
14th May 2023, 4:38 PM
Olga Restea
+ 1
You're welcome..
14th May 2023, 4:42 PM
Jayakrishna 🇮🇳