Thread: Problems compiling basic program

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    12

    Problems compiling basic program

    Hey guy,

    Im an engineering student who just started a programing class concerning C.

    Our first assignment was to write a basic program to calculate the area of a circle by the given guidlines. I took the program step by step, but the gcc command came back with three errors. Im sure its just a beginners mistake. Ive posted the code, and the errors. Any help would be greatly appreciated.

    -Cliff


    Code:
    /* The purpose of this program is to calculate the area and circumference
    of a circle using Pi as a constant.
        Written by: Clifton 
        Date: July 4th
    */
    #include <stdio.h>
    #define PI 3.1416
    
    int main (void)
    {
    // Local Declarations
       float circ;
       float area;
       float radius;
        
    // Statements
       printf("\nPlease enter the value of the radius: ");
       scanf("%f", &radius);
    
       cric  = 2  * PI    *radius;
       area  = 2  *radius *radius;
    
       printf("\nRadius is :        %10.2f", radius);
       printf("\nCircumference is : %10.2f", circ);
       printf("\nArea is :          %10.2f", area);
    
    return 0;
    }  //main
    -------------

    And the Errors


    -bash-3.00$ gcc program1.c
    program1.c: In function `main':
    program1.c:21: error: `cric' undeclared (first use in this function)
    program1.c:21: error: (Each undeclared identifier is reported only once
    program1.c:21: error: for each function it appears in.)
    Last edited by thestrap; 09-04-2006 at 12:57 AM.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    sorry, i failed to read about the code tags

    i promise never to do that again

    -Cliff

  3. #3
    Just kidding.... fnoyan's Avatar
    Join Date
    Jun 2003
    Location
    Still in the egg
    Posts
    275
    Open your favorite editor/IDE, go to line 21 and change cric to circ. Just a spelling error.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    thank you so much!

    its amazing how one stupid thing can ruin the whole thing.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    What's more amazing is how you could have saved yourself an hours time by just reading the warning message yourself.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    According to the file, you've been programming this for TWO months, and yet this appears to be the first time you've ever got an error message out of the compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    and Nothing Else Matters
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    117
    Maybe tis another one of his typo errors?
    It is not who I am inside but what I do that defines me.

  8. #8
    Register User andor's Avatar
    Join Date
    Aug 2006
    Location
    Novi Sad
    Posts
    42
    Cool indipendence day.
    What? Don't like my comment? Well everybody else have joke comment so why can't I add some too.
    Last edited by andor; 09-04-2006 at 07:00 AM.

  9. #9
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    Quote Originally Posted by quzah
    What's more amazing is how you could have saved yourself an hours time by just reading the warning message yourself.


    Quzah.
    Is this a condescending remark???

    im just starting with this stuff man. This is just a ciriculum requirement, not my life. I need help, not you trying to show your balls on the board.

    Cliff

  11. #11
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    Quote Originally Posted by Salem
    According to the file, you've been programming this for TWO months, and yet this appears to be the first time you've ever got an error message out of the compiler.
    sorry, idk why i wrote july 4th, i did it last night


    and im not sure who nightsky is ~twomers

    cliff

  12. #12
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by thestrap
    Is this a condescending remark???

    im just starting with this stuff man. This is just a ciriculum requirement, not my life. I need help, not you trying to show your balls on the board.

    Cliff
    It wasn't condescending. It was me wondering why you didn't just read the ........ing warning. Then you could have thought to your self, "Self, I do believe I have that spelled wrong, because I don't remember making my variable named cric. As a matter of fact, self, cric doesn't even sound like a real word. It most definitely doesn't sound like something I'd use to represent a circle."

    But I suppose I can't expect you to know how to ........ing read, since reading is probably just a ciriculum requirement, and not your life.


    Quzah.
    Hope is the first step on the road to disappointment.

  13. #13
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If you cannot understand that warning it's a wonder how you can use spell checker on any of your papers for college.

  14. #14
    and Nothing Else Matters
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    117
    quzah's got a point there... the warning says:

    program1.c:21: error: `cric' undeclared (first use in this function)
    ...and the rest of the errors is caused by this single error....

    hmm, unless you didnt know what "undeclared" means, you've got no excuse to overlook that simple typo... peace!!!
    It is not who I am inside but what I do that defines me.

  15. #15
    Registered User
    Join Date
    Sep 2006
    Posts
    12
    Quote Originally Posted by quzah
    It wasn't condescending. It was me wondering why you didn't just read the ........ing warning. Then you could have thought to your self, "Self, I do believe I have that spelled wrong, because I don't remember making my variable named cric. As a matter of fact, self, cric doesn't even sound like a real word. It most definitely doesn't sound like something I'd use to represent a circle."

    But I suppose I can't expect you to know how to ........ing read, since reading is probably just a ciriculum requirement, and not your life.


    Quzah.
    This is like reading japanese to me.....however circ and cric are different, the human eye reads the first and last leter of the word and gathers the filler without any thought. I read over the the "circ" several times and it didnt make any sense because of this. I completely understood that this was the error related section, but if i read over it several times correctly (human error)wtf am i supposed to do? I apologize for being slightly dislexic, and not understanding the errors of the first program ive ever done in my life.
    And im not writing anymore papers in college thankfully.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with basic c program.
    By Uber Fr0g in forum C Programming
    Replies: 6
    Last Post: 09-26-2005, 06:59 PM
  2. Problem with basic encryption program.
    By mmongoose in forum C++ Programming
    Replies: 5
    Last Post: 08-27-2005, 04:41 AM
  3. GPA Program Problems
    By Clint in forum C Programming
    Replies: 3
    Last Post: 04-28-2005, 10:45 AM
  4. Some basic array or structure program
    By kimimaro in forum C Programming
    Replies: 15
    Last Post: 03-10-2005, 10:55 AM
  5. Replies: 6
    Last Post: 07-10-2002, 07:45 PM