error message

This is a discussion on error message within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hi: I am using this C compiler called miracle C. I did type in all the codes and was hoping ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,336
    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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21