Run your first C program
Lets see compile and run a program on Linux platform.
1. Create a file named myprogram.c and write the following.
int main (void)
printf (“This is my first program.\n”);
2. Save the file. In the command prompt, type
gcc -c myprogram.c
A new file named myprogram.o will be created in the same directory. This is the object file.
3. lets create the executable file for source code. Type
gcc -omyprogram myprogram.o
An executable named myprogram will be created.
4. To run the program, type
“This is my first program.” will be displayed on the terminal.
If you did not see any error, then your first program has been successfully executed. Congratulations!