Learn C Language

Learn C Programming Language Step By Step. It’s easy to learn c programming language with real-life examples and hands-on. We are trying our best to deliver quality content.

C Program Structure

« Previous Page                                                                                                                              Next Page »

Before we start learning basic building blocks of C programming language, let us understand the C Program Structure. In the upcoming tutorial, we will take it as a reference.

Parts Of C Program?

A c program basically consists of the following constituents:

  • Preprocessor Command
  • Functions
  • Variables
  • Comments
  • Statements and Expression

Let us understand the C Program Structure using a very simple example.

Diving Deep To Understand All Parts

  • The first line of the program #include <stdio.h> is a preprocessor command, which tells a  compiler to include stdio.h (Standard Input Output Header File) file before going to actual compilation.
  • The second line int main() is the main function. It is the position from where the execution of C Program begins.
  • Coming To the third line: /*…*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called multiple line comments in the program. For single-line comment you can use //.
  • Next line printf(…) is another pre-built function available in C which causes the message “Welcome To Mycteacher!” to be displayed on the screen. The \n is an escape sequence that is used to move the cursor to the next line. So, you will see out Welcome To Mycteacher! and cursor blinking just below W of Welcome.
  • The last line return 0; terminates the main() function and returns the value 0.

Compile and Execute In Code:: Blocks

You can use the same method for other modern IDE(Integrated Development Environment). Let’s begin the journey of writing source code, Compiling source code and executing that code.

  • Open Code:: Blocks
  • Either Press ctrl+shift+n together or Click on File -> Empty File
  • Copy above code and paste there
  • Press ctrl+s to save the file. Name the file anything you want with an extension of .c, FirstProgram.c
  • To compile the program, press ctrl+f9 together. Or click on build -> click on the first option (build).
  • If you want to compile and execute together then press f9. Or click on the build option, choose the build and run option.
  • To execute program press ctrl+f10 together.

Compile and Execute Using GCC

Let’s see how people are writing source code, Compiling source code and executing that code using GCC.

  • Open any text editor you have. For example, notepad,notepad++.
  • Copy above code and paste.
  • Press ctrl+s to save the file. You can take any filename with an extension of .c. For example, FirstProgram.c
  • Please note the location where you saved the file. For example, E:\Mycteacher. This indicates that FirstProgram.c is saved inside a folder Mycteacher of E drive.
  • Open Command Prompt. Go to the folder where you saved the file. In my case, I will type e: and press enter. Then I will type cd Mycteacher and press enter.
  • To Compile code type gcc filename.c. In my case, I will type gcc FirstProgram.c
  • If there are no errors in your code, the command prompt will take you to the next line and would generate a.out executable file.
  • Now, type a.out to execute your program.

Top Book Suggestion

The two books on C Programming Language that I Personally Recommend. I really loved reading these books. These books are listed for quality content, easy steps, and affordable price. You can get it from Amazon and Flipkart. 

Check The Price On Amazon:

1. C Programming Beginner’s Guide

2. Head First C: A Brain-Friendly Guide

Check The Price On Flipkart:

1. Introduction to C Programming 

2. Head First C: A Brain-Friendly Guide

« Previous Page                                                                                                                              Next Page »

Buy Premium Courses At Lowest Price. Become A Certified Developer Today!

Best Books Selected by Our Experts

Buy Premium Projects At Lowest Price

Ebooks Written by Our Experts


Buy Premium Courses At Lowest Price. Grab Golden Opportunity To Become A Certified Developer Today!

Useful Links

Pin It on Pinterest

Share This