labprog8-2010

labprog8-2010 - numbers read from the keyboard. */

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Swinburne University School of Engineering and Science HES1300 Robotics & Mechatronics Project 1 Laboratory assignment 8: Similar to week 7, write a program (using arrays) that reads 5 inputs from a keyboard (floating point numbers). Then, write separate functions to print the mean, the maximum, the minimum and the standard deviation of those values in a simple table. Pay particular attention to the way different functions communicate with each other using arrays. Standard deviation of a series of n numbers (x i s) with mean of μ is given by: A simple implementation of the average function is as follows. /* This program finds the average, the largest, the smallest and the median of the five floating point
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: numbers read from the keyboard. */ #include<stdio.h> /* Prototype declarations */ float myAverage(float inputs); int main() { float inputs[5],avg; int i; for(i=1;i<=5;i++) { printf("Enter the number %d\n",i); scanf("%f",&inputs[i-1]); } avg = myAverage(inputs); printf("The average of the given values is: %f \n",avg); return(0); } /* This function adds all the inputs and returns the average. Input: An array of float with 5 elements Output: average of the 5 input numbers. The function returns a floating point value. */ float myAverage(float inputs) { float temp=0.0; int i; for(i=0;i<5;i++) { temp += inputs[i]; } return (temp/5.0); } 1 ) ( 1 2 n x n i i...
View Full Document

This note was uploaded on 09/29/2010 for the course C++ c taught by Professor Lauren during the Three '10 term at Swinburne.

Ask a homework question - tutors are online