473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How Do I Rewrite This In C Using Functions?

#include <stdio.h>
#include <math.h>


/* Define the variables. */
int main ()
{
int N;
float Q[5000];
float max;
float min;
float range;
float average;

int J;
float V=0.0, Sq, De;

/* print program header message. */

printf("\n\n CSCI 210 -- C Assignment 5\n");
printf(" ******************************\n");
printf("Reading, Computing, and Printing from an Array.\n\n");

/* Declare variables for the file and open and scan it. */
int s;
FILE * numbers;
numbers = fopen("asgn5-1.txt","r");
while (N = (fscanf(numbers,"%f", &Q[s]) == 1))
{
s++;
}

/* prints all the values in the array. */
int k;

for(k=0; k<s; k++)
{
if (k%6 == 0)
{
printf("\n %f", Q[k]);
}
else
{
printf("\t %f", Q[k]);
}
}

/* Calculate the max.*/
max = Q[0];
for (k=1; k<s; k++)
{
if(Q[k] > max)
max = Q[k];
}

/* calculate the min. */
int h;
min = Q[0];
for (h=1; h<s; h++)
if(Q[h] < min)
min = Q[h];

/* calculate the range. */
range = max - min;

/* calculate the average. */
int sum=0;
int e;
for (e=0; e<=s-1; e++)
sum += Q[e];

average = sum/s;

/* calculate the standard deviation. */

for (J=1;J<s-1;J++)
{
Sq =(Q[J] - average) * (Q[J] - average);
V = V + Sq;
}

De = sqrt(V/s);

/* print all the values.*/
printf("\n\nCSCI 210 - Assignment 5");
printf("\n*********************** \n\n");
printf("Maximum Value: %5.3f \n", max);
printf("Minimum Value: %5.3f\n", min);
printf("Range Value: %5.3f\n", range);
printf("Number of Values: %5d\n", s);
printf("average: %5.3f\n", average);
printf("Standard Deviation: %5.3f\n", De);

fclose(numbers);

return 0;
}
Oct 31 '06 #1
1 1967
RADAR
21
Northern Illinois University student friend I want you if it is appropriate for you send me the exact question then i will try to solve it.If you wolud not try to make it clear to understand what is expected from you under that topic.I do not hide my mail adress:
tinb_usa@hotmail.com
respects...
Oct 31 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: HALLES | last post by:
HELLO ! I seek to use a form too fill a file without putting a server on my computer. I am no C# programmer, i can do some things in Javascript but IT CAN T WRITE REWRITE APPEND A FILE ON LOCAL...
1
by: darrel | last post by:
We're using URL rewriting (Isapi Rewrite). Is there any way to grab the pre-rewritten URL or can you only grab the rewritten one? I'm assuming you can't (as that's sort of the point of URL...
188
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection -...
1
by: baroque Chou | last post by:
Thanks for the help available on msdn, I have succesful done the rewrite job. But there are 2 problems arise: 1.when I try to rewrite the url from say: www.yoursite.com/beverages.aspx to...
14
by: Stan Canepa | last post by:
This post is mostly for discussion. Why rewrite in .NET? Just a general discussion not related to any specific details. I was just looking to see what reasons developers are looking to, to help...
3
by: bxstylez | last post by:
rewrite this program (sum,average) using functions, possibly arrays? #include<stdlib.h> #include<stdio.h> main() { FILE *finpt, *foutpt;
7
by: Frank | last post by:
Years ago I wrote a program to read .lnk files, modify the data and rewrite the file. I modified it slightly and used it for .pif files. I can't find it nor can I find the API calls I used. ...
1
by: polilop | last post by:
Is there a URL rewrite module that allows to rewrite url by looking at the database. Egxample: http://www.somesite.com/object.aspx?objectCountryId=1&objectId=22 now i look into the database, see...
3
by: aag | last post by:
Hey there! I've got an URL rewrite issue that I'm wondering if the masters out there can help with :) I have a site that resides at (for example) foo.com - it's a full site with tons of pages...
1
by: mazdotnet | last post by:
Hi all, I've installed the new Microsoft URL Rewrite Module for IIS 7.0 http://www.iis.net/downloads/default.aspx?tabid=34&i=1691&g=6 on both my laptop (Vista Home Premium) and my desktop...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.