Skip to content

Instantly share code, notes, and snippets.

@snadahalli
Created October 1, 2013 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snadahalli/6773643 to your computer and use it in GitHub Desktop.
Save snadahalli/6773643 to your computer and use it in GitHub Desktop.
Sum & average of n numbers.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double sum =0, i=0, n , grade=0;
cin >> n;
do
{
i++;
cin >> grade;
sum = sum + grade;
}
while(i<=n);
cout << "Average = "<< sum/n<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment