answersLogoWhite

0


Best Answer

Example in Java:

int total = 0;

int i = 1

while (i <= 10)

{

total += i;

i++;

}

System.out.println("The sum of the first ten numbers is " + total);

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: 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?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

What is the difference between while loop and for loop in matlab?

A while loop executes code inside the while block continuously until the said condition is not true. A for loop contains three parts. The first part is carried out prior to the for loop, the middle part is executed by the for loop until it is no longer true, and the final part is performed at the end of each go round of the loop.


C program find magic number less than 1000?

#define int main (void){/*Algorithm*/1. First Initialize the number that is Random no2. Using while loop if the person got it, then the loop stop if not the loop continues.}return(0);


How to draw Flowchart to print prime numbers from 1 to 100 using while loop in c language?

c the book mastering c


What type of loop is For k equals 7 to maxValue?

A very poorly defined loop. By default the looping index increases. The loop, as described in the question will not terminate if "maxValue" is less than 7.


Compare While with for Statements?

The while loop is the more general one because its loop condition is more flexible and can be more complicated than that of a for loop. The condition of a for loop is always the same and implicit in the construction. A for loop stops if there are no more elements in the collection to treat. For simple traversals or iterations over index ranges it is a good advice to use the for statement because it handles the iteration variable for you, so it is more secure than while where you have to handle the end of the iteration and the change of the iteration variable by yourself.

Related questions

Is it possible to use a for loop in place of a while loop?

Yes. while loop consist of only condition statement to make for loop look as while loop we can use syntax shown below: for(;condition;) eg: for(;i&lt;=n;)


Is possible to use a for loop in place of a while loop?

Yes, it's easy:Old: while (expression)statementNew: for (; expression;)statement


How do you write a program with do while loop so that the output is 123456 equals 720?

How do you write a program with do while loop so that the output is 123456 =720


When should use a while loop over a do loop?

Generally speaking a for loop looks like this:for(Initialization;condition;increment){Do Stuff}whereas a while loop looks like this:while(condition){Do Stuff}Before the while loop there should be some initialization and somewhere in the Do Stuff section there should be statements that change the condition. Those statements are analogous to the increment section of the for loop.


What is main different between do while and while?

If you want to execute a statement which is in while loop at least one time you can use do- while loop. this is why because initially first statements will be executed then condition will be checked. but in case of while first condition will be check then statements will be executed


How do you get the ouput as 11111 using while loop?

int i = 0; while( (i++) &lt; 5 ) { printf("1"); }


What is a nested loop in java?

A nested loop is a (inner) loop that appears in the loop body of another (outer) loop. The inner or outer loop can be any type: while, do while, or for. For example, the inner loop can be a while loop while an outer loop can be a for loop.


What is a C programming to calculate the sum of 1-2-3-4-5 and so on using while loop a for loop and a do while loop?

#include using std::cout;using std::endl;int main(){int number(1);cout number;//using loop forint sum(0);for(int i(1); i


What are the similarities of while loop and a do while loop?

They both loop


How can you define null statement in loop in C programming?

If you are using for loop for(;;); or you can also define condition and iterations but the loop has to close there itself without any statement inside it. In the similar way you can define while and do while loop without any statement.


C program algorithm for simple interest using while loop?

Not used


Steps in loop control?

C has 3 types of loops. do { foo += increment; } while(foo != bar); This loop will continue until foo equals bar but will execute the loop at least once, even if foo equals bar. The variable increment may be changed within the do loop. It is imperative that the value foo can reach equality with bar, otherwise an endless (run for ever) loop condition exists. ***** while(foo != bar) { foo += increment; } The loop will continue until foo equals bar but will not execute if foo equals bar. The variable increment may be changed within the do loop. It is imperative that the value foo can reach equality with bar, otherwise an endless (run for ever) loop condition exists. ***** for (foo = 0; foo &lt; bar; foo+= increment) { } The loop will continue until foo equals bar. The stepping amount is controlled by the value of increment. The value of increment could be changed inside the loop.