Saturday, March 19, 2011

Run C programs in Linux

Hello friends,
Before we proceed I would like to thanks MR.Richard Stallman (founder of GNU project) for free software movement.
I will now demonstrate you the steps that you can follow to run C PROGRAMS on any linux distribution like ubuntu,Linux 10 mint,OPEN SUSE,fedora etc.

You might have used microsoft c,Turbo c or Borland c compiler but, GNU compiler is little different from all of it as it compiles c programs faster and produces the output at the terminal.

You can also create, compile and run your any C PROGRAMS. All you have to do is get any linux distribution installed on your computer machine.

1)To create your c program go to your Terminal from Applications >> Accessories >> Terminal
2)Just Type gedit hello.c &
Now here gedit is command to open Linux's default text editor afterwards hello.c is your filename. Now just hit enter.
3)Now You will see one brand new file open next to your eyes. Now just type any your first c program or copy paste following code:

#include< stdio.h >
int a,b,c;
printf("Enter two number for an addition\n");
printf("Total of two number is %d\n",c);

4)before main() I have included standard input output files so that printf scanf function works
(note: please remove white spaces which is before the stdio.h and after stdio.h word because right now google is treating it as html tag )

5)Now Save the file.
6)Go back to terminal just type gcc -o hello hello.c
and hit enter.
7)Now you can type ./hello and hit the enter and see the output.

This is how you can run any c programs in linux operating system. At the next tutorial we will see how to run python programs in linux operating system.

so bye for now,

Enjoy & be open.
long live linux

1 comment:

  1. Thanks for review, it was excellent and very informative.
    thank you :)