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.

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad