Thread: First day with C

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    1

    First day with C

    I started doing the tutorial about noon today. After 6 hours of reading, rereading, and trial and error with Dec-C++, I finally managed to write something that works.

    Code:
    #include <stdio.h>
    
    	
    int main()
    {
        int input;
        
        printf( "Choose a door, or keep your prize!\n" );
        printf( "1. Door1\n" );
        printf( "2. Door2\n" );
        printf( "3. Door3\n" );
        printf( "4. Keep your prize of $100\n" );
        printf( "Selection: " );
        scanf( "%d", &input );
        switch ( input ) {
            case 1:            /* Note the colon, not a semicolon */
                printf( "You Win $20!\n" );
                getchar();
                break;
            case 2:          
                printf( "You Win $0!\n" );
                getchar();
                break;
            case 3:         
                printf( "You Win $300!\n" );
                getchar();
                break;
            case 4:        
                printf( "You keep your $100!\n" );
                getchar();
                break;
            default:            
                printf( "Wrong Key! Exiting Now!\n" );
                getchar();
                break;
        }
        printf( "Thanks for playing!\nGoodbye!\n" );
        getchar();
    
    }
    It's horribly basic, I know... I'm just currently proud of myself for writing it and it not borking my computer.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    LOL.

    Well it depends how badly you want to learn how to code and what you want to do with it. If you are really motivated and willing to learn, then learning C can be quite enjoyable.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    Omaha, Nebraska
    Posts
    116
    Awesome!
    Grats man!
    keep it up and have fun with it.
    good lookin' code by the way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Should I learn a FULL language first?
    By Raeliean in forum Game Programming
    Replies: 8
    Last Post: 07-16-2005, 06:59 PM
  2. error with code
    By duffy in forum C Programming
    Replies: 8
    Last Post: 10-22-2002, 09:45 PM
  3. cant get code to work
    By duffy in forum C Programming
    Replies: 13
    Last Post: 10-20-2002, 05:23 AM
  4. debug program
    By new_c in forum C Programming
    Replies: 3
    Last Post: 03-18-2002, 11:50 PM
  5. Simplified code
    By soonerfan in forum C Programming
    Replies: 2
    Last Post: 12-05-2001, 03:50 PM