Switch to full style
C++ code examples
Post a reply

C++ Average example

Thu Nov 13, 2008 1:50 pm

Calculate the average of numbers in C++
cpp code
#include <stdio.h>
int main(void)
{
// Read the numbers.
printf("Enter: ");
int n1;
int n2, n3;
scanf("%d %d %d", &n1, &n2, &n3);

// Compute the sum and average.
double sum = n1 + n2 + n3;
printf("Mean %d %d %d is %f\n", n1, n2, n3, sum/3.0);

return 0;
}




Post a reply
  Related Posts  to : C++ Average example
 Average SQL command     -  
 Average of an array. Please help     -  

Topic Tags

C++ Algorithms