Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Select the output for the following set of code?

  1. static void Main(string[] args)
  2. {
  3. int i = 5;
  4. for (; Convert.ToBoolean(Convert.ToInt(i)); Console.WriteLine(i--)) ;
  5. Console.ReadLine();
  6. }

a)b)c)1d)

user-image
Question ajoutée par Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb
Date de publication: 2016/10/20
Mohammad Riyazuddin
par Mohammad Riyazuddin , Web Developer , PYD, King Saud University

Output : 5

               4

               3

               2

               1

 

Explanation: Initial value of i is 5 , the "i" value will be converted as boolean and going to check the condition with that boolean value.,as the iteration part is concerned it displays the values of  "i" and decrement it's counter  until i becomes 0 then loop will terminate.

 

mohammed hussamuddin hussamuddin
par mohammed hussamuddin hussamuddin , C Technical Lead , Infosys

Console.ReadLine will unable to read any data because the for condition check evaluate to false initially so no out put.

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?