C program structure chapter is important chapter. Here you will learn to compile and execute C
program using GCC. You will also know C program structure diagram. Moreover, it is easy to compile
and run C program online. However, you must practice C programs to understand the structure.
Parts of C program
C program will have different parts. These are pre-processor commands, variables and functions.
Even comments, statements and functions are part of this list. You can check code of following
program. Here you will understand how to write a program using C.
How to compile and execute C program
Now you will understand steps to compile and run C program. You will also learn how to save source code in file. In addition steps for compiling and running program are here.
Steps to compile and run C program using gcc
- Firstly, you must open text editor
- Secondly, add code
- Next you must save the file with name.c (here name is your file name)
- After this you must open command prompt
- From there go to directory (this is where you saved file)
- Later type gcc name.c
- Press enter as this will compile code
- However, in case of errors in code, command prompt takes you to next line
- It will then generate a.out executable file
- You must remember that you type a.out
- Because this will only execute your program
- Finally, you can check output on screen
Points to remember
You must see that GCC compiler is in path. In addition, you must run it in directory. This directory
should have source file. Moreover, this source file is name.c
So, you understood C program structure functions. You also learnt how to compile and execute C
program using gcc. Moreover, we clearly stated C program structure example. It is better that you
check examples for compile and run C program online.
No comments:
Post a Comment