Pages

Banner 468 x 60px

 

Sunday, September 23

How to Run "C Program" in Linux

1 comments
Hello friends,

sometimes we need to run the C programs in the Linux Box,

Today i am showing you people how to run an "C language program" from the Linux System.

In linux we can use the gcc command to run C programs

Most of the time by default the gcc installed in the linux.

Type the following command to verify the gcc is installed :

which gcc

output

/usr/bin/gcc

To find the version of the gcc

gcc --verision

output

gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Writing first program:

Open the vi editor

$vi Hello.c

and type the following lines of code

#include<stdio.h>
main (void)
{
    printf("Hello World");
    return 0;
}

Compiling Program

Compile the program and make executable

$gcc Hello.c -o Hello

To execute the program

$./Hello

Output

Hello World



1 comment:

Unknown said...

Linux is free, open source and intended as a non-propriety operating system for the masses. Thanks a lot admin to sharing this wonderful blog on Linux. Also Learn Linux from the best Linux Online Certification in India at CatchExperts.com

Post a Comment