Question: Can someone help me with my C++ code? For some reason its not running and the stof is not working so I am trying new
Can someone help me with my C++ code? For some reason its not running and the "stof" is not working so I am trying new methods.
The output should be:
5
1
5
Average: 3.66667
Here is the data in the rainfall_data.txt file
0.00 0.00 T T 0.03 1.70 0.00 0.27 T 0.00 0.00 0.01 0.02 1.24
#include
using namespace std; int main() { string inFileName="rainfall_data.txt"; fstream inFileStr(inFileName.c_str(), ios::in); float myArray[200]; float value; float avg; int i = 0; int z = 0;
while(inFileStr >> value) { if(value='T') { value = 0.01; } myArray[i] = value; i++; }
int l=0; for(int k=0;k
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
