Thread: error message

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    7

    Question error message

    Hi:
    I am using this C compiler called miracle C.
    I did type in all the codes and was hoping it will RUN. But I get
    this error message that says "line 15: unrecognised types in comparison
    'if (radius < 0) area=0'

    here is codes for the program:


    #include <stdio.h>
    #define PI 3.14159
    float process(float radius);
    main()
    {
    float radius, area;
    int count, n;
    printf("How many circles?");
    scanf("%d", &n);

    for (count=1; count<=n; ++count) {
    printf("\nCircle no.%d: radius=?", count);
    scanf("%f", &radius);

    if (radius < 0)
    area=0;
    else
    area=process(radius);
    printf("Area=%f\n", area);
    }
    }

    float process(float r)
    {
    float a;
    a=PI*r*r;
    return(a);
    }


    Your help is appriciated

    Thanks

    SAMSEIED

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Seems OK to me - compiles with gcc

    You could try
    if ( radius < 0.0 )

    Oh, and Miracle C is the saddest piece of ........ for a compiler ever!

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Yeah. You usually don't want to be mixing types with ints. There's no concrete rule about it (although I think there should be) but the compiler usually just makes assumptions. I would've thought there should be some indentation or something with the lines under the if statement, but if it compiles OK, I guess it's no biggie.,

Popular pages Recent additions subscribe to a feed