• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

looping problem please help it is very urgent

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He means create something to check to see if you ever hit the true condition - like:
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks ,i got my doubt cleared
lakshmi
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic