is this right

This is a discussion on is this right within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> int main() { int age; int name; printf( "enter your name" ); scanf( "%d", &name ); if ...

  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 10: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,399
    Try sticking to one thread.
    is this right
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    Stop spamming the board with identical questions.

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