PropellerAds
Posted by : Unknown Wednesday, 24 December 2014

This is a sample code to calculate average using array and for loop... for understanding array and for loop you may consult our explanation on that.

#include<iostream>
#include<conio.h>

using namespace std;

void main() {
int arr[10] = { 0 };
int result = 0;

for (int i = 0; i < 10; i++){
cin >> arr[i];
}

for (int i = 0; i < 10; i++){
result += arr[i];
}

result /= 10;

cout << "The average is: " << result;
}

Leave a Reply

Subscribe to Posts | Subscribe to Comments

PropellerAds
PropellerAds

Popular Post

Powered by Blogger.

- Copyright © BSCS -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -