Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Calculate Average in C program

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 30-10-2009
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.

Reply With Quote
  #2  
Old 30-10-2009
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
}
Reply With Quote
  #3  
Old 30-10-2009
Member
 
Join Date: May 2008
Posts: 2,286
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;        
    }
Reply With Quote
  #4  
Old 30-10-2009
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);
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Calculate Average in C program"
Thread Thread Starter Forum Replies Last Post
Need help to calculate Average of time in Microsoft Excel NardO MS Office Support 2 23-02-2012 04:06 PM
How to calculate the average time in excel Rao's Windows Software 1 06-01-2012 09:48 PM
How to calculate Highest Average marks using c++? Madaleno Software Development 5 16-02-2010 08:25 PM
Program : How to calculate the median in C++? UseME Software Development 3 19-01-2010 11:08 AM
What is the Program to calculate the percentage? Ekpah Software Development 3 08-12-2009 11:30 AM


All times are GMT +5.5. The time now is 09:44 AM.