0
basic algorithms on loops
I am really struggling with the summing, counting, Searching for an objects , maximum, minimum , arrays, abstract classes and interfaces in Java
6 Answers
+ 1
Your question covers too many areas.
It would be better to ask each of these as a single question. Maybe ask one question a day, and spend each day understanding answers you receive.
0
for (int i = 1; i <=5; i++)
The first group is initialization of loop pointer. It runs only once on loop start.
The second group is condition when loop should continue do something, if condition is true then it works.
The last group is changing our pointer (just adding 1 to it) - it happens at the end of each repetition of loop.
for (int i = 1; i <= 5; i++)
System.out.println(i);
Output:
1
2
3
4
5
0
when we write tests, all the areas I have mentioned are included, so i am only good at UML diagrams and i identifying classes from problem statements
0
Thanx Bartosz Pieszko , can you please include arrays in your loops, like searching for an element in an array using a for loop
0
Tozo Tozo
int element = 5, t[100];
for (int i=0; i<100; i++)
t[i] = 100-i;
for (int i=0; i<100; i++)
if (t[i] == element)
cout << "Found element at index " << i << endl;
0
thank you very much Bartosz Pieszko