Report Bug

Qus

Which of the following code is most efficient?

Code 1

for(var number-10;number>=1;number--)
{
document.writeln(number);
}

Code 2

var number=10;
while(number>=1)
{
document.writeln(number);
number++
}
Qus

निम्नलिखित में से कौन सा कोड सबसे कुशल है?

Code 1

for(var number-10;number>=1;number--)
{
document.writeln(number);
}
Code 2

var number=10;
while(number>=1)
{
document.writeln(number);
number++
}


A. Code 1
B. Code 2
C. Both Code 1 and Code 2
D. Cannot Compare


Solution
A. Code 1



Explanation

Code 2 is incorrect which infinite loop i.e. its never end because it increase the variable value by one and condition is >=1that never meet.

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad