Thursday 23 January 2014

Starting C : A series of Chapters to learn C

So far you have gone through the solved examples in my Blogs.I have received a lot of emails demanding “Step by Step learning of C Language'” in easy to understand language with illustrative examples.

So here we go….

Chapter 1: Basic C Program Structure

Prior to learning,the basic program structure, here are some rules to be followed while writing program,

* C being case-sensitive ; entire program should be typed in Small Case letters(By entire program, we mean all the commands and keywords being used in the program).

* Each new statement should begin with a new line.

* To mark the finishing of each statement, place a semicolon(;) at the end of statement.

The Basic C Program Structure

#include <headerfile.h>                      (1)

main()                                                 (2)

{                                                          (3)

//statements                             (4)

}                                                         (5)

 

Understanding the Program structure

(1) #include <headerfilename.h> , Here, # is known as Preprocessor(executes prior to compilation of rest of the program code) and include is a directive(simply we can call it as command). This statement is used to add any of the pre-existing header files, so that we may use the functions defined within those header files.

Some of the prominently used header files are: stdio.h, conio.h,math.h,string.h etc

(2) main(), this the executable body of your program. When you Compile and execute your program, the Compiler search for this function block in your code. If not found, your program even won’t get compiled.

In C, it is not mandatory to place void or other return type before main(), that’s why i have skipped writing that.

(3)   Beginning of main block structure. All your program statements are written within these Opening and Closing Blocks except the functions defined by you and External variables(will be discussed in later chapters).

(4) All your program statements  such as : Variable declarations, Input-Output Statements etc.

(5) End of the main() block structure. In C only, function definitions and External variable declarations are only allowed after end of main() block.

Here comes to end the Intro to C. Now, try the simple questions,

Question 1: Write the basic typing rules to be followed while writing C Program?

Question 2: Discuss the Basic C Program Structure in details?

Question 3: What will happen, if your program contains all statements except the main()?

Question 4: How many types of Basic Program statements are there in C?

Question 5: What is meant by the terms Preprocessors and Directive. Why they are used in C Program?

In the Next Chapter, we will be learning to create our First C Program  and Output Functions.

 

For suggestions and Queries on any topic mail me at softech.ratlam@gmail.com

No comments:

Post a Comment