You don't show what type dt is, but since t is defined as an int, the calculation 1.082/dt and comparison to t will be truncated to an int. It's not clear why you're not using a simple for loop since you want to write files 1 through 5.
Actually I want to calculate y[i] which is varying for every iteration of t for different point values i.
so, i cant run the code for only i=1 to 5. which will fail my case.
Calculation part is not problem. problem is in if loop. please help me to write file if only it passes if loop in the nested loop structure. that too only 5 files i dont want to write n number of files.
My assumption about files 1-5 was based on your other thread asking about naming the files.
In this case, the if statement at line 7, will result in writing once to each of six files.
The files will be result-91, result-181, result-271, result-361, result-451 and result-541. i.e. the if statement checks t for one of six possible values, and only if t matches does it open a file with that suffix, does one write to it and closes it.
I'm guessing that you're counting on the for loop at line 4 to iterate through the 40 values, although that is far from clear. Since it's not clear how you want to separate the values into 5 files, I can't suggest anything at this point.