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 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz