aspose file tools*
The moose likes Beginning Java and the fly likes looping  problem please help it is very urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "looping  problem please help it is very urgent " Watch "looping  problem please help it is very urgent " New topic
Author

looping problem please help it is very urgent

lp
Ranch Hand

Joined: Nov 08, 2000
Posts: 52
hi
i had a problem in how to implement the loop conditions .the problem is as follows:
int num,harray[],raaray[],rindex;
i want to check the condition whether value of num is less than or equal to the values of rarray [i] where i = 0 to rindex .incase this conditon is true i want to increment the value of num to num+1000 ,store the value of this num in haaray[0].(p.s rindex value is always less than the array size).and call another function called heap
Incase the conditon is false for all the values of raaray[rindex] then i want to insert haaray[0]=num and called the function called heap.
i have been trying to figure how to write down this code .my code what i have wriiten is as follows but i am not sure whether it is correct or not so please let me know
the code is as follows :

The doubt which i have is whether the if conditoin will check for all the i values or not .and i want to go to the assignment portion in the else case only after all the i values have been checked and not satisfied .but i am not sure whether this is implemented in this code which i have wriiten .Please let me know
Thanks
Lakshmi
(edited by Cindy to format code)
[ March 07, 2002: Message edited by: Cindy Glass ]
Rene Marot
Greenhorn

Joined: Jun 27, 2001
Posts: 9
Hello.
I am not sure of what you want but what you write will do the test for each value in raaray and will do the 'then' or the 'else' depending on the current value. If you loop 10 times you do the 'if then else' statement tem times.
If you want to make it only one time you have to make a loop to test each value then rizing a flag to said all tests failed and outside of the loop making your 'if then else' stament.
hope it helps.
Bye.
lp
Ranch Hand

Joined: Nov 08, 2000
Posts: 52
hi
i want to test for all the values of raaaray[rindex],incase it fails for all the values of rindex then only i want the else part to be executed and not each and every time .
I could not understand what u meant by flag also .
thanks
lakshmi
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
He means create something to check to see if you ever hit the true condition - like:
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
You know I am looking at this thinking that we are answering your question - but you are asking the wrong question.
What is it that you are actually trying to accomplish here?
lp
Ranch Hand

Joined: Nov 08, 2000
Posts: 52
Thanks ,i got my doubt cleared
lakshmi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: looping problem please help it is very urgent