![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Average in awk | saint2006 | Shell Programming and Scripting | 6 | 06-19-2008 03:09 PM |
| how to average in awk | saint2006 | Shell Programming and Scripting | 4 | 06-04-2008 12:29 PM |
| calculate average of multiple line data | smacherla | HP-UX | 4 | 05-23-2008 05:39 PM |
| Use awk to calculate average of column 3 | grossgermany | UNIX for Dummies Questions & Answers | 6 | 07-27-2007 02:29 PM |
| calculate average of column 2 | onthetopo | UNIX for Dummies Questions & Answers | 0 | 07-06-2007 09:16 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
calculate average
I have a file which is
2 3 4 5 6 6 so i am writing program in C to calculate mean.. #include<stdio.h> #include<string.h> #include <math.h> double CALL mean(int n , double x[]) main (int argc, char **argv) { char Buf[200],SEQ[100]; int i; double result = 0; FILE *fp; fp=fopen(argv[1],"r"); while(fgets(Buf,20,fp)) { sscanf(Buf,"%s",SEQ); x=SEQ; //printf("%s\n",SEQ); } fclose(fp); { for (i = 0; i < n; i++) result += x[i]; result /= n; return result; printf("%f", result); } } But it is showing segmentation fault any solution? |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|