October 4, 2015

# The Program Structure

That’s how code is organized, the program structure !

Welcome to the Newbie Programmer Series. From Today (here tonight) We will start our new topic called The Program Structure. With the last post, we did some really great practical applications. But I think this post is gonna be a theoretical one. But once we clear the concepts, all the coding stuffs is awesome. So if you are new to this series, please go to index (click here) and read out all the previous parts so that you can easily understand what is going down below.

All the coding stuffs we have did so far are very simple, clean and clear. We have made very little programs. But these small programs are for learning purpose. The video games we play and the software you are reading my blog in is written the same way but these are very very large. A complete software like video games usually contains millions of lines of codes and hundreds of files ! If we just write all the code again and again, the software may go on to trillion lines but what we do is that we use some cool programming tricks that help us to make our work easy. In this new topic “The Program Structure” we will learn such things. We will study the structure of a program and learn how to code in a better and organized way. But before that, lets discuss some terms to get an overview of what we will be learning in this new topic.

## Functions

It’s easy for those who know maths, but don’t worry I am here. Function means a specified work. For example, what is the function of a switch ? Its to turn the appliance ‘on’ or ‘off’. Or, What is the function of the ‘jump’ button in a video game ? Its to make your hero jump. To each of these things, there is assigned a specific work to do. That is a function. In mathematical sense, you can understand a function as a formula. For example : f (x) = 3x This is a very simple function. The function is ‘f’ . It takes the value of x and then the spefic work is to multiply that  by 3.

## PreProcessing

Preprocessing is like replacing the code in a program before the Program Starts. It is like : If we command the computer to replace PI with 3.14 then the following thing : Circumference = 2 * PI * radius will automatically converted into Circumference = 2 * 3.14 * radius We can do many other things too but yet intro only :D !

## Libraries

I think we have already discussed it but let’s do it again. A library contains a lot of different functions. The code we write is like a legal document which contains just the different laws and rules number. And the computer himself has to go to the library to see what that Rule Number means. Like we always use “printf” in our programs. But do you know what is the code of printf itself ? The code of the function printf is stored in a library and the computer goes to that library to see how printf works and then gives us the desired outputs.

A big program contains a lot of variables and files. Its like A big software is consists of hundreds of different small programs. Just as a computer game, A single big software contains a program for graphics, a program for sound and music, a program for keeping the scores etc. So it has to go with a lot of source files and a lot of variables and values etc. Even we have to create our own library. So to keep everything easy we use header files. Header files is like a hotel Register. In a Single Big Building, there are a lot of different rooms with different people. But register keeps the records of all the things. Similarly, header files keeps a record of all the functions and variables and other useful stuffs that will be use in a program. So that is just an overview of what we are going to learn in this new topic. From tomorrow, we will start function, the first part of this new topic. So Stay Connected !

#### You might also like:

(prev)
(next)

(rand) Some Practical Applications of Control Flow
(rand) Setting up the Computer for programming
(rand) Elementary HTML tags