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.

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad