Understanding headers, variables and functions

Submitted by: 

Understanding headers, variables and functions

In this part you will learn:

1. Pseudo code
2. Headers
3. Functions
4. Variables and data types

In this tutorial I will teach you the basic stuff that is need for programming in c. First thing to learn is pseudo code.

Pseudo code:
When you want to start coding a problem the first thing before writing an algorithm is to write the solution of the problem that is in your mind in simple English. Pseudo code has no specific pattern it’s just a way to writing the solution of the problem in simple English. It’s a good thing to use especially when you are new to coding.

Let’s look at an example
Problem: Write a program to add two numbers given by the user

1.Declare three numbers number1 , number2 and answer
2.Input number1 and number 2.
3.Add number1, number2 and store in answer.
4.Print answer on screen.


At the start of the c program we write some statement like #include etc they are called preprocessor directive. They are needed for making a C program. They actually provide us with different functions which are needed for coding in C. It’s example is just like a car shop where you can get tyres , engine and casing etc and you can make your own car. Similarly headers provide you functions using which you can make a whole new program.


They are actually blocks of code which provides a certain functionality in a program. For example printf function has the functionality of printing text on the screen. The scanf function will have the functionality of taking input form the user. A sqrt function has the functionality of taking square root of a number etc. You will easily understand functions later on.

The Main function:

In every C program there is a function known as the main function. It is responsible for calling all other functions and you can say it is the heart of a program without which a program cannot execute. You will have better understanding of it later on.

Variables and Data types:

In mathematics we deal with integers and decimal numbers and unknown variable etc, in the same way in order to represent these there are certain data types in c language

Type – Representation in C – Occupies Memory

integer - int %d - 4 bytes
Float (for decimal numbers) - float %f - 4 bytes
character - char %c/%s - 1 byte
Double (big decimal numbers) - double %lf - 8 bytes

int num1;
char alphabet;
float average;
double PI;


Variables can have any defined data type but they should follow some variable naming rules

1.Number and characters can be used to name a variable
2.Variable should start with an alphabet or underscore.
3.Variables are case sensitive e.g int num1 and int Num1 are not same.
4.Variables should not have the same name with reserved c key words.

In the next tutorial we will start coding.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.