Write the following code using while loop.
sum=0;
for (k=20; k<100); k=k+2)
sum=sum+k;
count<<"\nSum="<<sum;
Answers
Answered by
0
Answer:
While loops. Many computations are inherently repetitive. The while loop enables us to execute a group of statements many times. This enables us to express lengthy computations without writing lots of code.
The following code fragment computes the largest power of 2 that is less than or equal to a given positive integer n.
anatomy of a while loop
TenHellos.java prints "Hello World" 10 times.
PowersOfTwo.java takes an integer command-line argument n and prints all of the powers of 2 less than or equal to n.
Mark me as brainliest
Similar questions
Computer Science,
3 months ago
Economy,
3 months ago
English,
3 months ago
Computer Science,
7 months ago
History,
7 months ago
Math,
1 year ago
English,
1 year ago
English,
1 year ago