Find the answer to your Linux question:
Results 1 to 4 of 4
i used this program from a tutorial to see if it works Code: #include <stdio.h> #define KILOS_PER_POUND .45359 main() { int pounds; printf(" US lbs UK st. lbs INT Kg\n"); ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast crashandburn0420's Avatar
    Join Date
    Jun 2005
    Location
    Naugatuck, CT
    Posts
    590

    first C program


    i used this program from a tutorial to see if it works
    Code:
    #include <stdio.h>
    #define KILOS_PER_POUND .45359
    main()
    {       int pounds;
    
            printf(" US lbs      UK st. lbs       INT Kg\n");
    
            for(pounds=10; pounds < 250; pounds+=10)
            {       int stones = pounds / 14;
                    int uklbs = pounds % 14;
                    float kilos = pounds * KILOS_PER_POUND;
                    printf("   %d           %d   %d        %f\n",
                                       pounds, stones, uklbs, kilos);
            }
    }
    And i copiled it with
    Code:
    gcc /home/steven/samp.c -o samp
    how do i run it?

  2. #2
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    I think
    Code:
    ./samp
    should work :0
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  3. #3
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,619
    To add to what dylunio said, the -o switch specifies the name of the compiled program. So when you build a program with the -o switch, simply type:
    Code:
    ./<argument for -o switch>
    If you don't use the -o switch, gcc will call it a.out

    Bryan
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

  4. #4
    Linux Enthusiast crashandburn0420's Avatar
    Join Date
    Jun 2005
    Location
    Naugatuck, CT
    Posts
    590
    ook thank you that worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •