Languages [3i Infotech Placement]: Sample Questions 468 - 469 of 546

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 468


Describe in Detail


Differentiate between a for loop and a while loop? What are it uses?


Difference between Loop and a While Loop
for (initialization; condition; iteration)


//body of ‘for’ loop


while (condition)


Statements; // body of ‘while’ loop


For loop runs until the number of predefined iterations are completedWill loop until the condition presented is completed. Condition variables are modified inside the loop
‘For’ loop initialization is never repeated.In while loop if initialization is done during condition checking, then initialization is done each time the loop iterates.

Use of for loop:

  • Used when number of iterations are known beforehand.

Use of while loop:

  • Used when end conditions is known but no idea about the exact number of iterations.

Question 469


Write in Short

Short Answer▾

How can a ‘::’ operator be used as unary operator?


  • The scope operator can be used to refer to members of the global namespace.
  • Because the global namespace doesn՚t have a name, the notation:: member-name refers to a member of the global namespace.
  • Useful for referring global namespace members whose names are hidden by names declared in nested local scope.
  • Unless we specify to the compiler in which namespace to search for a declaration, the compiler simple searches the current scope, and any scopes in which the current scope is nested, to find the declaration for the name.
Given the Image is Scope Operator be Used as Unary Operator

Developed by: