Thread: Please help me? I'm a little bit confused

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    5

    Please help me? I'm a little bit confused

    First of all. I'm still learning this c programming and I'm writing a software to calculate velocity(from physics). In this program, a person must enter initial velocity, acceleration and time taken to calculate the final velocity. But, after I have ran it, the result was always the same, no matter what number the input was. Please help. Here's the code:

    #include<stdio.h>
    #include<math.h>

    int main()

    {
    int integer1, integer2, integer3, result, multiply;

    printf("PHYSICS: Chapter 2 and 3,\n\n");
    printf("CHAPTER 2\n");
    printf("-Distance\n");

    printf("Enter initial velocity : ");
    scanf("%d", &integer1);
    printf("Enter acceleration : ");
    scanf("%d", &integer2);
    printf("Enter time taken : ");
    scanf("%d", &integer3);

    multiply=integer2*integer3;
    result=integer1 + multiply;



    printf("The velocity is : %d\n", &result);

    return 0;
    }

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Code:
    printf("The velocity is : %d\n", &result);
    Lose the & before result.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    5
    thanks

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    And please read the intro thread describing how to post code, and use code tags.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bit level permutation function
    By zxcv in forum C Programming
    Replies: 2
    Last Post: 07-27-2008, 01:26 PM
  2. 16 bit compilar or 32 bit compilar
    By rajkumarmadhani in forum C Programming
    Replies: 16
    Last Post: 12-04-2007, 09:48 AM
  3. Bit Manipulation Questions
    By CPPNewbie in forum C++ Programming
    Replies: 7
    Last Post: 08-12-2003, 02:17 PM
  4. Copy bit to bit
    By Coder2Die4 in forum C Programming
    Replies: 15
    Last Post: 06-26-2003, 09:58 AM
  5. Bit manipulation
    By pkalluri in forum C++ Programming
    Replies: 5
    Last Post: 05-12-2003, 07:06 AM