#include<stdio.h>

#define MAX 4
main()
{
  float A[MAX];
  int i;
  
  for(i=0;i<MAX;i++)
     scanf("%f",&A[i]);
  return 0;
}

im using Visual C++ and doesnt give me any compilation error it keeps giving me a run time error after i enter the 1st number i can't figure out whats wrong :S help?

If that is the actual code, it shouldn't give you any error.

I'm using Visual C++ and doesnt give me any compilation error it keeps giving me a run time error after i enter the 1st number i can't figure out whats wrong :S help?[/QUOTE]

The only reason this code should give you error is if you input something else that float, let's say letter. So please post what number did you entered for its first input?

And please, write:

int main()

instead of simply

main()

The only reason this code should give you error is if you input something else that float, let's say letter [...]

scanf() would return an EOF in that case.

This code will given an run time error only if you have miss "&" in the scanf section...Please check your actual code if you have the &A and not just A in the scanf section...

The only reason this code should give you error is if you input something else that float, let's say letter [...]

scanf() would return an EOF in that case.

No it will not. It will return zero in that case.

EOF is only returned upon reaching end of input. If there is input in the stream that does not correspond to what is expected (via the format string) scanf() returns the number of fields successfully read. If there is one value to be read, and none are, the return value is zero.

Not that it matters: the return value of scanf() is not being checked.

In any event, the code that is posted is probably different from the code being compiled. And the difference is where the error is.

>No it will not. It will return zero in that case.
Correct. EOF would be returned ONLY if there's input failure before any data could be successfully read.

>If there is one value to be read, and none are, the return value is zero.
In this case when the user enters the wrong input a mismatch occurs and zero is returned.

#include<stdio.h>
#include<math.h>
int main()
{
  float a,x,y,w,g,s,area,b,c,hg,radius,ho;
   
    printf("enter the value of one side:");
    scanf("%f",&a);
    printf("enter the lengths:");
    scanf("%f%f",&x,&y);
    w=2*x;
    g=2*y;
    s=(a+w+g)/2;
    area=3*sqrt(s*(s-w)*(s-g)*(s-a));
    printf("the area of the triangle is:%f",area);
    b=(2*area)/(3*(w+x));
    c=(2*area)/(3*(g+y));
    
    radius=(a*b*c)/(4*area);
    
    ho=sqrt((9*radius*radius)-(a*a+b*b+c*c));
    
    hg=(2/3)*ho;
    printf("the diatance is:%f",hg);
    
    
    
    
    system("pause");
    return 0;
}

i got the area
but the distance is giving the value-1.#IND00 ,i think the value of points are very very long so cant take if can u give me a solution to it expect that for importing a BIGFLOAT library..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.