Results 1 to 4 of 4

Thread: Calculate Average in C program

  1. #1
    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. #2
    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. #3
    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. #4
    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);
    }

Similar Threads

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

Posting Permissions

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