Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

Make money selling software. Check this out here

Hosted clickbank mall. Check this out here


Sedo - Buy and Sell Domain Names and Websites project info: programmershelp.co.uk Statistics for project programmershelp.co.uk etracker® web controlling instead of log file analysis

   Misc

   Amazon

   Links

    


Running average
 

 

Description

This program calculates a running average based on what a user enters.

Code

/*
This program calculates an average of the numbers entered
*/
#include <stdio.h>

int Average(int i);

int main()
{
int num;
do{

printf("Enter numbers ( -1 to quit ).\n");
scanf("%d",&num);
/*if number is not -1 print the average*/
if(num != -1)
printf("The average is %d", Average(num));
printf("\n");

}while(num>-1);

return 0;
}

int Average(int i)
{
static int sum = 0, count = 0;
sum = sum + i;
count++;
return sum / count;
}

Information

tested using Visual C++ 6

 

 

 

 

Download

average.txt


 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
check network connection(VB)
Ohms law example(C)
Disk file systems in VBScript(VB)
wmi and soundcard(VB)
processor info using WMI(C Sharp)
display list of items in My pictures folder(VBScript)
basic addition example(Darkbasic)
scrolling message in a text box(Javascript)

    




Copyright © 2003 by programmershelp.co.uk