Krishna Rajput Singh
Is it compulsory to initialize a variable in the first segment of the for loop or can we initialize it before the loop starts?
By Krishna Rajput Singh in .NET on Aug 27 2014
  • Krishna Rajput Singh
    Aug, 2014 27

    No,it is not compulsory to initialize a variable in the first segment of the for loop .You can ever initialize the variable before the loop starts .In that class ,the first segment will only have a semicolon,as shown in the following codes. numeric num-0; for (;num<=4;num=num+1)

    • 2
  • Rahul Prajapat
    May, 2015 27

    No,it is not compulsory to initialize a variable in the first segment of the for loop .You can ever initialize the variable before the loop starts .In that class ,the first segment will only have a semicolon,as shown in the following codes. int num=0; for (;num<=4;num=num+1)

    • 1


Most Popular Job Functions


MOST LIKED QUESTIONS