Is it compulsory to initialize a variable in the first segment of the for loop or can we initialize it before the loop starts?
Krishna Rajput Singh
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)
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)