Thread: need help with some basic stuff

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

    need help with some basic stuff

    Hello,

    1. I AM A COMPLETE C++ NEWBIE
    ok, maybe not totally, but i need a bit more explanation then the averege person

    2. I am coding a ecosytem simulation which is not dynamic (hence meaning that there is no chance involved). It's based on this mathetmatical model -

    (a/b * s) + (-c/d * s) + (a/b * s)


    Basically, the person inputs two numbers which symoblize a ? out of ? chance of something being created, multiplied by the seconds. Then the person inputs two numbers which symbolize a ? out of ? of something being killed/destoryed, multiplied by the seconds. The next step is basically step 1. The remaining number is the end amount of this one specific speicies (i'm doing an ecosystem sim).

    Here is what I need to know:

    1. for step two, how do i make the number negative?
    2. how do i make this friggen think work? LOL! put it this way, i'm not that bad of a coder, but i'm a horrible debugger, and i couldn't find an error if my life depended on it. please tell me any obvious mistakes.

    Here is the code so far -

    Code:
    #include <stdio.h>
    main()
    {
          int a,b,c,d,e,f,g,h,i,j,k,l,m;
          printf("\first number for creation");
          scanf("%d",&a);
          printf("second number of creation ");
          scanf("%d",&b);
          printf("number of seconds ");      
          scanf ("%d",&c);
          d=a/b*c
          printf("\first number of destruction");
          scanf("%d",&e);
          printf("second number of desturction ");
          scanf("&d",&f);
          printf("number of seconds ");
          scanf ("&d",&c);
          h=e/f*c
          printf("\first number of creation");
          scanf("%d",&i);
          printf("second number of creation ");
          scanf("&d",&j);
          printf("number of seconds ");
          scanf ("&d",&c);
          l=i/j*c
          
          m=d+h+l
          printf("the final amount is %d /n,l");
    }
    Thanks in advance,

    JOlszewski

  2. #2
    Registered User Afrinux's Avatar
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    46
    (a/b * s) + (-c/d * s) + (a/b * s)
    what about changing the equation to make things easier for you.
    I believe that +(-c/d * s) is the same as - (c/d * s) meaning your equation will be the same as
    (a/b * s) - (c/d * s) + (a/b * s)
    Code:
    int equation;
    equation = (a/b * s) - (c/d * s) + (a/b * s);
    if( equation >= 0){ positive}
    else{ negative }
    hope it helps.
    Mas

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    > printf("\first number for creation");
    Watch your use of \ inside strings - You're printing a form-feed character here

    > d=a/b*c
    All your calculations lack a ; at the end

    > printf("the final amount is %d /n,l");
    / is not the same as \
    The value needs to be outside the string
    Say
    printf("the final amount is %d\n",l);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic stuff but dont work.
    By peckitt99 in forum C++ Programming
    Replies: 5
    Last Post: 09-05-2006, 03:20 AM
  2. References vs Pointer vs copying and storing stuff in classes
    By Monkeymagic in forum C++ Programming
    Replies: 20
    Last Post: 09-01-2006, 09:40 AM
  3. Basic Graphics programming in C, please help
    By AdRock in forum Game Programming
    Replies: 3
    Last Post: 03-24-2004, 11:38 PM
  4. Basic httpd server
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 07-28-2002, 06:14 PM
  5. Your stuff
    By smog890 in forum C Programming
    Replies: 6
    Last Post: 06-13-2002, 11:50 PM