Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
here is my program please correct it .it comes error call of non function.


C#
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<iomanip.h>
#include<stdlib.h>
#include<dos.h>
#include<io.h>

void main()
{
FILE *fp;
int n;
float med,j;
clrscr();
cout<<"HOW MANY NOS.? ";
cin>>n;
cout<<"ENTER SOME RANDOM NOS.";
fp = fopen("random.txt", "w+");

/* write some data to the file */
for(int i=1;i<=n;i++)
{
cin>>j;
fprintf(fp,"%f\n",j);
}
/* close the file */
fclose(fp);
fp=fopen("random.txt", "r+");
//fseek(fp, 0, SEEK_SET);
i=0;
float mean=0;
float arr[20];
while(i<n)
{
fscanf(fp,"\n%f",&arr[i]);
mean=mean+arr[i];
i++;
}
cout<<"store";
for(i=0;i<n;i++)

{Bin= (NumBins * (X - Xmin)) / (Xmax - Xmin);
if (Bin < 0) Bin= 0; else if (Bin >= NumBins) Bin= NumBins - 1;
cout<<"\nbin is :"<<ele(arr[i]/n);

}

//***************************MEDIAN*****************************
int temp;

for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(arr[j]<arr[i])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
int div;

cout<<"mean is : "<<mean/n;
if(n%2!=0)
{
med=(n+1)/2;
cout<<"\nmedian is :"<<arr[med-1];
}
else
{
div=n/2;
med=(arr[div]+arr[div-1])/2;
cout<<"\nmedian is :"<<med;
}

//********************Eucledian Distance***********************************

float eucl[20];
fseek(fp, 0, SEEK_SET);
for(int p=0;p<n;p++)
fscanf(fp,"\n%f",&eucl[p]);
cout<<"\n";
for(int f=0;f<n;f++)
for(int k=0;k<n;k++)
{
  temp=eucl[f]-eucl[k];
  cout<<"\nEucledian Distance of "<<eucl[f]<<" with respect to "<<eucl[k]<<" is "<<temp;
}
fclose(fp);
getch();
}
Posted
Updated 3-Aug-11 4:56am
Comments
Herman<T>.Instance 3-Aug-11 10:56am    
in which line the error is raised? did you debug your code?
Mohibur Rashid 3-Aug-11 11:05am    
what compiler are you using?

1 solution

Do yourself and us a favour: indent your code.
It is a lot easier to read, understasnd and debug if it looks like this:
C++
float eucl[20];
fseek(fp, 0, SEEK_SET);
for(int p=0;p<n;p++)
   fscanf(fp,"\n%f",&eucl[p]);
cout<<"\n";
for(int f=0;f<n;f++)
   for(int k=0;k<n;k++)
      {
      temp=eucl[f]-eucl[k];
      cout<<"\nEucledian Distance of "<<eucl[f]<<" with respect to "<<eucl[k]<<" is "<<temp;
      }
fclose(fp);
getch();
I would also strongly recommend meaningful names for all variables, an increas in commens, and the use of '{' and '}' at all times when you are beginning. I.e. even if you have a single line of code in a for loop, use brackets: That way if you need to add another, it is obvious that it is or isn't in the loop.

Use the "Improve question" widget to edit your question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900