Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication2.cpp : Defines the entry point for the console application.
- //
- #include<fstream>
- #include<iostream>
- #include<string>
- #include<cstdlib>
- #include<ctime>
- #include "stdafx.h"
- using namespace std;
- int main()
- {
- ifstream fin("rainfall.txt");
- double number = 0.0, sum = 0.0, average = 0.0;
- int count = 0;
- do
- {
- fin >> number;
- sum = sum + number;
- count++;
- } while (number != -999);
- average = sum / count;
- cout << "The average is " << average << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment