How you can run a c program in Linux?

last updated in Categories , ,

Q. I’ve a c program and I’d like to run in Linux.

A. C program need to compile and run in Linux using cc or gcc command. When you invoke GCC (GNU C Compiler), it normally does preprocessing, compilation, assembly and linking for you. For example to compile hello.c program , type the following command:
cc -o hello hello.c
gcc -o hello hello.c

It will compile and produced an exectuable file called hello. To run program type:

If else statement in C Program

last updated in Categories , ,

Q. Can you give me example for If else statement in C Program under Linux or TC?

A. C follows universal syntax for if..else. You can use any complier GNU Linux gcc or UNIX or old good TC.

if..else syntax

General if..else syntax is as follows:

if ( condition ) {
else  {

If given condition is TRUE, expr_set1 will get executed.
If given condition is FALSE (not TRUE), expr_set2 will get executed.

if..else example

Following example will find out large number from given input:

int main(){
        int x,y;
        printf("Enter value for x :");
        printf("Enter value for y :");
        if ( x > y ){
                printf("X is large number - %d\n",x);
                printf("Y is large number - %d\n",y);
        return 0;

How to see output of C program in Linux or UNIX

last updated in Categories , , , , , , ,

I am a new user of Linux operating system but not to C programming language. At my university we are using Turbo C compiler under DOS/Windows XP to write and compile C programs. Under Linux I wrote a small program called test.c. How do I compile and see the output of C program in a Linux when using Fedora Linux?