Hi Arthur,
From the code, you are coming to Mathematica from C. I use both, and 99.9% Mathematica. In the code below, I convert to Mathematica syntax. (* This is a comment *) and * is not needed to invoke multiplication, a space is fine, but not needed after a leading number. You use For, but most often Table is better, at least more concise. NumberForm is a wrapper used for output, it should be used after all calculation, but before printing. There is a lot of information to be found in The Virtual Book. It can be found by searching the help system, or at this link: Virtual Book
Here is code as an example. (I made up a function for ks.) I also attach as a notebook, so it can be executed without deleting all the Out cells.
In[1]:= nwwa = {};
In[2]:= nkka = {};
In[3]:= For[j = -4, j <= 4, j++,
(* calculate w *)
w = 16 (0.5 + 0.1 j);
(* append it *)
nwwa = Append[nwwa, w];
(* calculate ks *)
ks = Sqrt[2] w;
(* append it *)
nkka = Append[nkka, ks];
];
In[4]:= nwwa
Out[4]= {1.6, 3.2, 4.8, 6.4, 8., 9.6, 11.2, 12.8, 14.4}
In[5]:= nkka
Out[5]= {2.26274, 4.52548, 6.78823, 9.05097, 11.3137, 13.5765, \
15.8392, 18.1019, 20.3647}
In[6]:= result = Transpose[{nwwa, nkka}]
Out[6]= {{1.6, 2.26274}, {3.2, 4.52548}, {4.8, 6.78823}, {6.4,
9.05097}, {8., 11.3137}, {9.6, 13.5765}, {11.2, 15.8392}, {12.8,
18.1019}, {14.4, 20.3647}}
In[7]:= formattedResult =
result /. {x_, y_} -> {NumberForm[x, {3, 1}], NumberForm[y, 6]};
In[8]:= Export["c:\\temp\\mathematica1.dat", formattedResult, "Table"];
In[9]:= check = Import["c:\\temp\\mathematica1.dat"]
Out[9]= {{1.6, 2.26274}, {3.2, 4.52548}, {4.8, 6.78823}, {6.4,
9.05097}, {8., 11.3137}, {9.6, 13.5765}, {11.2, 15.8392}, {12.8,
18.1019}, {14.4, 20.3647}}
In[10]:= ListPlot[check, PlotLabel -> "Mathematica can plot this!",
Frame -> True, FrameLabel -> {"w", "ks"}]
Attachments: