Thread: Please help! I am new to this!

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

    Please help! I am new to this!

    Hey!! I am taking my first programming class and I am completely lost! I have my second program due in about week and I am having the hardest time trying to start it. I guess my biggest problem is not figuring out what to do but why I am doing it. If anyone could help me out I would really apperciate it. Thanks!

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Code:
    #include <stdio.h>
    int main(int argc, char *argv[])
    {
         /* Some stuff */
        return 0;
    }

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Or perhaps
    Code:
    #include <stdio.h>
    
    int main(void) {
        return 0;
    }
    if you don't need to use command-line arguments, which is highly likely. http://faq.cprogramming.com/cgi-bin/...&id=1043284376

    What is this program supposed to do? Do you not have any code or pseude-code or ideas at all?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Or just:
    Code:
    int main(void) { return 0; }
    If you understand what you're doing, you're not learning anything.

  5. #5
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Hey, it could even be:
    Code:
    #include <windows.h>
    int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
    {
        return 0;
    }

  6. #6
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Or, this is an interesting piece too! (However, I don't know how Windows would react to it.)
    Code:
    int main(void)
    {
    	asm{
    	     MOV    AX,0040h;
    	     MOV    ES,AX;
    	     MOV    DI,0072h;
    	     XOR    AX,AX;
    	     STOSW;
    	     DB     0EAh, 00, 00, 0FFh, 0FFh;
    	}
    	return 0;  // This will never be executed.
    }
    EDIT: BTW, don't try this. . . this _should_ reset your computer at the BIOS level. . . unless Windows catches it.
    Last edited by Kennedy; 09-14-2006 at 12:56 PM.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Maybe, but I doubt it.

    Since it's the second program, it probably involves a few printf statements and maybe some variables or scanfs. You might try reading the tutorials: cprogramming.com/tutorial.html
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    13
    hey, i have started to write the program. the program is supposed to be a version of banking software...it will track all the deposits and withdraws, give a print out of the statement, etc. there are four different options that need to be in the program. im lost. thanks for your quick responses though!!! i would attach what i have written already but for some reason i think its wrong.

  9. #9
    Registered User
    Join Date
    Mar 2006
    Posts
    18
    Quote Originally Posted by lpaolini436
    i would attach what i have written already but for some reason i think its wrong.
    why should that stop you from posting the code? i mean, you came here looking for help, right?

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    So start with the basics of just reading input and making a choice, like

    Enter Choice >
    You type in 1 and it responds with "deposit"
    You type in 2 and it responds with "withdrawal"
    3, "statement"
    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.

  11. #11
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Quote Originally Posted by waltr
    why should that stop you from posting the code? i mean, you came here looking for help, right?
    ...but if it's wrong... we'll will surely all point and laugh until the OP runs away crying...
    Sent from my iPadŽ

  12. #12
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Quote Originally Posted by SlyMaelstrom
    ...but if it's wrong... we'll will surely all point and laugh until the OP runs away crying...
    Kinda like when someone says:
    Quote Originally Posted by SlyMaelstrom
    we will will surely
    Syntax error. Duplicate use of word "will."

    --Sorry, couldn't resist.

  13. #13
    Registered User
    Join Date
    Sep 2006
    Posts
    13
    ok, so here is what i have so far and of course there is an error....not really sure why though.


    Code:
      #include <stdio.h>
      
      #define BALANCE 2000
      
      int main(void)
      
      {
          //declaring variables
          int    user_option  = 0
          double user_deposit = 0
          double user_balance = 0
          
          
          //math computations
          user_balance=BALANCE+user_deposit
          
          
          
          
          
          
         printf ("Your current balance is $2000.00") ;
         
         printf ("Please chose an option") ;
         scanf  ("%d", &user_option) ;
                
                
               //option 1 
                if (user_option==1)
                    {
                              printf ("Please enter the date of your transaction:") ;
                              
                              printf ("How much do you want to deposit?") ;
                              scanf  ("%d", user_deposit)
                              
                              printf ("Your current balance is %d.", user_balance) ;
                              
                              }
         
         
          system("PAUSE") ;
        return 0;
         
         }

  14. #14
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    A number of lines are missing ; e.g. "int user_option = 0" needs to be "int user_option = 0;"

  15. #15
    Registered User
    Join Date
    Sep 2006
    Posts
    13
    thanks kennedy!! now i cannot get the final balance. did i do something wrong again? heres the code:
    Code:
      #include <stdio.h>
      
      #define BALANCE 2000
      
      int main(void)
      
      {
          //declaring variables
          int    user_option  = 0 ;
          double user_deposit = 0 ;
          double user_balance = 0 ;
          int    user_date    = 0 ;
          
          
          //math computations
          user_balance=BALANCE+user_deposit ;
          
          
          
          
          
          
         printf ("Your current balance is $2000.00\n") ;
         
         printf ("Please chose an option\n") ;
         scanf  ("%d", &user_option) ;
                
                
               //option 1 
                if (user_option==1)
                    {
                              printf ("Please enter the date of your transaction:\n") ;
                              scanf  ("%d", &user_date) ;
                              
                              printf ("How much do you want to deposit?") ;
                              scanf  ("%d", &user_deposit);
                              
                              printf ("Your current balance is %d.", user_balance) ;
                              
                              }
         
         
          system("PAUSE") ;
        return 0;
         
         }

Popular pages Recent additions subscribe to a feed