Thread: is this right

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    34

    is this right

    Code:
    #include <stdio.h>
    
    int main()
    
    {
        
        int age;
        int name;
        
        printf( "enter your name" );
        scanf( "%d", &name );
        if ( name == reece ) {
             printf( "wow thats my name aswell\n" );
             }
             else {
                  printf( "you are &name\n" );
                  }
             printf( "enter your age" );
             scanf( "%d", age );
             if ( age == 17 ) {
                  printf( "wow I'm that age\n" );
                  }
                  else {
                       printf( "your name is &name\n" );
                       }
                       getchar();
                       return 0;
                       }
    i wrote this on my own, just for fun to see if it works but it gets an error on the if ( name == Reece ); line... ne suggestions on it?

    and also is this the best way to write a code like?
    Last edited by psycho88; 12-01-2005 at 11:25 AM.

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    34
    also it says...

    C:\Documents and Settings\Reece\My Documents\Untitled1.cpp In function `int main()':

    12 C:\Documents and Settings\Reece\My Documents\Untitled1.cpp `reece' undeclared (first use this function)

  3. #3
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Stop spamming the board with identical questions.

Popular pages Recent additions subscribe to a feed