How loops can be beneficial in a program?
968405
Saves you having to type the same code a hundred times to get the same tasks done a hundred times in succession.\n\nA loop lets you use the same code over and over again. Very beneficial.\n\n///
445101
A Well written program should be explaned clearly with comments, must be indented appropriately, must be efficient in code reuse (Use functions/procedures wherever possible) and be free of any errors ofcourse\n\nGood luck with your assignment
593080
*** pseudocode ****\n\n\n$max = $array[0];\n$min = $array[0];\n\nfor( $x=1; $x <= $size_of_array; $x++ )\n {\n     if($array[$x] < $min)\n       {\n          $min = $array[$x];\n       }\n\n     if($array[$x] > $max)\n       {\n          $max = $array[$x];\n       }\n\n}\n\n\n\n\nhave fun\n\n\nt
44673
Your program ran into code it couldn't execute or data it couldn't address.\n\nIf you wrote the code, look for things like uninitialized pointers, overwritten data structures, and anything else that could corrupt your code or data.
383056
what kind of program are you doing?? all i know is visual basic stuff
253284
#include <stdio.h>\n\nint main(void) {\n\nint i, j, count; //C Sucks, wait till you take java\n\nfor(i=1; i<=1000; i++){&#92;&#92;goes through all numbers 1 to 1000\n    count=0;\n    for(j=2; j<i; j++)&#92;&#92;goes through all numbers 2 to i\n    {\n     if(i%j==0)&#92;&#92;checks to see if it i is evenly div. by i\n        count++;\n    }//nested for\n    if (count ==0)\n        printf("%d&#92;n", i);\n}//for\n\nreturn 0;\n}//main\n\n\n//Hope that helps!
907694
I'm not sure if I get your question right, but I think you're referring to lookup tables (or LUTs).  I think the easiest way to explain the use of these, is through an example from the old days.  Twenty years ago (or so), it took a long time to calculate the sine of an angle.  So if you needed to make a lot of calculations with sines in them, what you did was: calculate the sines of each of the 360 degrees (or more if you needed a better precision) and store the results in an array.  If you then needed the sine of n, all you needed to do is look up the value of the n'th entry in the array --which was a lot faster and therefore efficient than calculating the value.\n\nOf course, this only helped if you needed to calculate a sine more than 360 times, otherwise you wouldn't win back the overhead of pre-calculating all those sines.\n\nHTH.\n\nPS: a conclusion of what I wrote should be that using arrays with[in] loops does NOT *always* improve efficiency.
399780
I assume that since you're asking about linked lists, you can probably read code to some extent. =)\n\nAnyways, here's a link to a project on CodeProject that does exactly what you're asking for; along with source code so that you can see how it's done.
968428
I wouldn't worry about an extra if eating up any extra CPU's.  Believe me, the difference would be negligible...\n\nIf you really want to speed up your code, do this:\nint x = 0;\nfor ( ; x < 6; x++ ) {\ndoWork();\n}\n\nx++;\nfor ( ; x < 10; x++ ) {\ndoWork();\n}\n\nthat's about as fast as it gets.  It's more code bloat, but it does prevent the extra if().
370480
If you want to generate random numbers, almost every programming language I've ever come across has some function to generage the same sequence of random numbers every time. \nHope that helps.
129073
The code below will work.\n\nint main()\n{\nint aNum,i;\ncout<<"enter a number";\ncin>> aNum;\nfor(i=0;i<aNum;i++)\n{\nfor(j=0;j<=i;j++)//nested loop\ncout<<"*";// end of nested loop\ncout<<'&#92;n';\n}// end of outer loop\nreturn 0;\n}
615699
You can't usually sit down and write a program straight away. You have ideas, break the whole project down into managable pieces and solve each problem at a time. Then you can put it all together at the end. You develop new ideas along the way.
1049892
I'll leave it to somebody else to give you the best looking guy or girl.  I'd tell you the best looking girl out there is my wife, but as she isn't high profile I'll leave it to somebody else.\n\nA loop in computer terms (or in math when speaking of algorithms) is when a specific block of code repeats a number of times.  For example:\n\nLet x be the value 100\nWhile x < 200, do the following\n...Write the value of x to the screen\n...Add one to x\n\nThis basic algorithm will write the numbers from 100 to 199 to the screen.  It is a loop, but not infinite.\n\nLet x be the value 100\nWhile x < 200, do the following\n...Write the value of x to the screen\n...Add one to y\n\nThis is a classic accidental infinite loop.  It will print out '100' forever, because the loop modifies y, not x.  Infinite loop.\n\nYour question is how to check to see if a loop is infinite.  Loops are usually defined by a boolean condition.  If that condition cannot become false, the loop is infinite.  \n\nSometimes it the condition can't become false because of poor programming.  For example, a loop is told to read a file until it reaches the word "END".  If the file is corrupt and it never finds the word "END" it'll keep trying to read the file over and over.  The operating system will keep telling it it can't read any further, but it'll keep trying anyways.  In cases like this, programmers generally leave themselves alternate exit conditions, like reading until it reaches the word "END" or trying to read further returns an error.\n\nThere's no sure way to find out if a loop is infinite or not.  You could have a loop that keeps going until the user clicks the.  Is it an infinite loop?  No, because at any time the user can hit the mouse.  But if the user has a heart attack and dies, then it's infinite.  But that can't be detected.  \n\nThe standard alternative is what's called a "time out interval."  Take a communications program.  It goes out to a web address and tries to get some data.  It sits in a loop waiting for data to come back.  But if it sits in that loop for more than 10 seconds, it "times out" and gives up.  If it had waited 11 seconds it may well have succeeded, but the programmer decided that 10 seconds was enough to decide that it wasn't going to happen.\n\nSo if you're in a situation where you can't determine if your loop is infinite or not (that is, can't determine if the condition you're checking can ever become false) you can add a time out value and break out of the loop after a certain amount of time.  But for 99% of the loops you'll ever write, just carefully putting the loop together is sufficient.\n\nHope this helps.\n\n--------------\nRelevant Computer Science joke:\nQ: How did the programmer die in the shower?\nA: The shampoo bottle said "Wash, rinse, and repeat"
730496
iteration1: a = 3, b = 2\niteration2: a = 13, b = 8\niteration3: a = 51, b = 30\nloop exit:  a = 81, b = 30 // condition a = a + b executed before exit
256646
I'll put a bit of more information than the previous two answers.. or it'll seem like I'm answering for 2 points ;-)\n\nA for loop in C++ basically has the syntax:\n\nfor([initializations];[condition check];[updates])\n{\n  //statement1;\n  //statement2;\n}\n\nInitializations: Initialize counters, iterators.. any data to be set or reset before the loop starts executing. Multiple initialization statements can be provided in a comma-separated-list.\n\nCondition Check: While the condition is true, keep iterating through the loop. Dont make this a list.\n\nUpdates: Update iterators, indices, counters etc. which need to be updated with every iteration of the loop. Again this can be a comma-separated-list.
360717
let suppose in excel\n\nuse a line of code at top\n\nApplication.ScreenUpdating = False\n\nthis will simply disable screen refreshing when working in the codes so it will improve the speed.\n\nalso avoide using nested loops\nalways use long or integers don't use double or single variable types\n\nand remove the duplicate loops
764647
Work lots of problems....even if they are old homeowrk problems.  The repetitions will help you identify what type of operations you need to use in order to solve the problem.