answersLogoWhite

0

kk

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

Is for loop is faster than while loop in turbo c plus plus compiler?

No, why did you think so?


What is CPU usage small programm c plus plus?

Example: int main (void) { LOOP: goto LOOP; }


C plus plus for while loop example code?

The syntax for a for loop is:for (initialization; condition; increase) {statement;}for example:int arr[5] = {1, 2, 3, 4, 5};for (int i = 0; i < 5; i++) {cout


What is 1 plus 2 plus 3 plus 4 plus 5 plus 6 plus 7 plus 8 plus 9 plus 10 equals 55 how is it possible using while loop?

Example in Java: int total = 0; int i = 1 while (i &lt;= 10) { total += i; i++; } System.out.println("The sum of the first ten numbers is " + total);


What is an infinite loop in c plus plus?

An infinite loop is one sequence of commands that just repeats over and over again forever. When it comes to creating an infinite loop you can use the: for do while and do statements. using the keywords 'true'


How to complete this C plus plus End Of File controlled while loop program?

Add the missing parts.


What are some examples of loops in C plus plus?

The following example demonstrates all 4 loop structures in C++. #include&lt;iostream&gt; int main() { int i; std::cout&lt;&lt;"For loop...\n"&lt;&lt;std::endl; for(i=0; i&lt;10; ++i) std::cout&lt;&lt;i; std::cout&lt;&lt;'\n'&lt;&lt;std::endl; std::cout&lt;&lt;"While loop...\n"&lt;&lt;std::endl; i=0; while(i&lt;10) std::cout&lt;&lt;i++; std::cout&lt;&lt;'\n'&lt;&lt;std::endl; std::cout&lt;&lt;"Do-while loop...\n"&lt;&lt;std::endl; i=0; do { std::cout&lt;&lt;i; }while( ++i&lt;10 ); std::cout&lt;&lt;'\n'&lt;&lt;std::endl; std::cout&lt;&lt;"Goto loop...\n"&lt;&lt;std::endl; i=0; again: std::cout&lt;&lt;i; if(++i&lt;10) goto again; std::cout&lt;&lt;'\n'&lt;&lt;std::endl; } Output: For loop... 0123456789 While loop... 0123456789 Do-while loop... 0123456789 Goto loop... 0123456789


What is a while statement in turbo c plus plus?

A while statement is one type of looping statement. by which we can start a loop in our programs. while loop is precondition checking statement, because it first check its condition then loop will go to its body part. EX. while(i&gt;0) { //body part } here when i will &gt;0 then it will check it body part and execute it and display result.


What is an example of a do-while loop in C plus plus?

A do-while loop is best suited to loops that must execute at least once: srand(( unsigned)time(NULL)); int i; do { // pick a random number between 1 and 10 i = 1 + (int) (10.0*(rand()/(RAND_MAX+1.0))); std::cout &lt;&lt; i &lt;&lt; std::endl; } while( i!=10 ); In this example, the loop executes at least once and prints a random number. While the random number is less than 10, the loop reiterates, selecting another random number until the number 10 is selected. The exact same effect can be achieved with for and while loops but the code is much less readable as a result: srand(( unsigned)time(NULL)); int i=0; while( i!=10 ) { // pick a random number between 1 and 10 i = 1 + (int) (10.0*(rand()/(RAND_MAX+1.0))); std::cout &lt;&lt; i &lt;&lt; std::endl; } In the above example, we must initialise i before entering the loop for the first time. srand(( unsigned)time(NULL)); for(;;) { // pick a random number between 1 and 10 int i = 1 + (int) (10.0*(rand()/(RAND_MAX+1.0))); std::cout &lt;&lt; i &lt;&lt; std::endl; if( i==10 ) break; } In the above example we use an infinite loop and instantiate i within the loop. We can also replace for(;;) with while(1) to achieve the same result. Ultimately the do-while loop makes the most sense in this case. The infinite loop versions would only make sense if you wanted i to fall from scope at the end of the loop (which can't be done with a do-while loop since the conditional expression is outside of the loop). But the while loop makes the least sense because i must be initialised before entering the loop for the first time.


Hoe can you write a programme to claculate 1 plus 2 plus 3..100?

You add the numbers in a loop. Here is an example in Java:int sum = 0;for (int i = 1; i


Which loop does not have an entry condition in C plus plus?

The only loop that does not require an entry condition is the procedural goto loop: again: /*...*/ goto again; Although a do-while loop has no entry condition per-se, it still requires a mandatory entry condition into the second and all subsequent iterations. do { /*...*/} while (true); // mandatory entry condition into all but the 1st iteration And although a for loop's condition is optional, it is implicit: for (;;) {/*..*/} // implicit for ever loop for (;true;) {/*...*/} // explicit for ever loop


C program to print numbers 1 to n?

how do we use loops in c plus plus programing and what are basic differences between do,for and while loop