Thread: Calculate Average in C program

1. Member
Join Date
Feb 2006
Posts
185

Calculate Average in C program

I want to make a C program with a graphical interface that must be composed of 11 numbers (averages) with a "calculate" button that allow the calculation of the number.

2. Member
Join Date
Jan 2009
Posts
199

Re: Calculate Average in C program

Code:
```for(j = 0, j < 11, j++)
{
do
{

}  while
F[j] = input;
sum += input;
}
if(sum != 1.0)

else
{
for(j = 0; j < 11, j++)
Avg += (F[j]*X[j]);
Avg /= 11;
// output Avg
}```

3. Member
Join Date
May 2008
Posts
2,302

Re: Calculate Average in C program

// Calculating the average
Code:
```#include <iostream>
using namespace std;

int main()
{
cout << "Enter the number: ";
int i;
cin >> i;
double num;
double sumnum;
sumnum = 0.0;
for (int y = 1; y <= i; y++)
{
cout << "#" << x << " = ";
cin >> num;
sumnum += num;
}```

4. Member
Join Date
Dec 2008
Posts
177

Re: Calculate Average in C program

Code:
```#include <stdio.h>

float average(float z, float d) {
return (z + d)/2.0f;
}

/* main program - execution always starts here */
void main() {

float average(float x, float y);  /* Function prototype */

float val1= 1.0F;
float val2 = 2.0F;
float o = 0.0F;

o = average(val1, val2);
printf("\nThe average is: %f",  o);
}```

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•