C programming




Introduction

Before explaining C programming let us discuss what programming is ?????

 well programming is the set of instruction given to the computer , instruction to get our job done .

In our daily day-to-day life we also give instruction to others like “bring me that”  “complete the work” ,”go there” and etc .

So in computer science also we give instruction to the computer to get our job done like adding a bunch of numbers , finding solution to a mathematical problem , or doing some computational problem and so on
Like in English we follow grammar to complete our instruction like that we have specific way of giving instruction to the computer , and  as in our real life we have many languages to communicate similarly we have many languages we can use to write these computer instruction called programming languages and the instructions are called programs .

So that was a loose definition of programming language and programs

In the list of many programming language C is one of the oldest and popular programming language , it is small but can produce many complex programs and if you are interested in the history of C programming please visit this link  wikipedia C programming language

I won’t be describing a lot of detail on the theory part but still some information about C Language that I think you people should know

C Language is a procedural language that means it follows procedures or functions or sub routine in order to complete the task .
Well if you don’t know what a function is then not to worry you would know  later in the course but for now function can be defined as self contained unit of code
C Language is a multi platform language that means you can develop programs for almost all the major platform with C like windows , Linux , Unix etc , you just need a compiler and in case if you wonder what a compiler is , well I am going to explain it just wait for a moment

So that will be enough about the theory part , Now

What is the programming process?
The programming process follows like this



So first we have the source code that is the code we have written in C Language , we then compile the source code with a compiler , So compiler is a program that converts a user readable program to something that can be understood by a computer and after that we get a exe file or  executable file and then we run or execute the program

If the program executes well then its working fine but if not then it has a bug in it , a bug can be defined as a behavior of a program that we are not expecting , So in order to solve the problem we have to debug it , it’s the fancy way of saying “What Is Wrong In The Program”
We can start writing code in a command prompt which I find boring sometime so we would use a IDE  or what’s called as Integrated Development Environment , it’s a piece of software that we use to write our program and for this purpose I am using DEV C++ , its free and easy to install and use , you can download it from the following link Download

I hope you have downloaded it and install it

So to create a new program just do

File < New < Source File or just type ctrl + n (for new document)

Now we can write our program here

Let’s write our first program

main()
{
      printf("Hello World \n");
      getch();         
 }

That is it , now give a name to the program like “hello” with an extension dot c , so that will be “hello.c” and change the “save as type” dialog box to “c source file” and save the file
You can compile the program from going to the menu and

execute < compile (ctrl +F9)

and run the program by

execute < run (ctrl + F10)

The output of the program is to display “Hello World” message on the

console like

Now let’s examine the program

main()  {  }  - this called the main function , every c program should have a main function otherwise it won’t compile , at this point it might be difficult to understand what a function is but later it would be clear to you as we proceeds further but for now main is a function , 

every function has starting and closing round brackets following the function name and also opening and closing curly brackets which define the body of that function . Main is not the only function , there many more functions in C

function name ( )
{
Body of the function
}

Printf(“  “);  - well again this is also a function , and we do not see a body here don’t worry you will know about it later in the course but for now it’s a C function that accepts everything that is inside the double quotes and display it on the screen , that is the function of this function

printf(“ display this message on screen  \n“);

The semicolon – the semicolon is used to signify that “this is the ending of this statement” it’s like the “full stop” for programming language 
Statement ;

\n – slash n means new line , if you want to display two sentences one followed by other then use the \n character and if you don’t use it ,everything will appear in the same line

getch() – again we can see that it is a function , the function of this function is to hold the console until it gets an input from the keyboard and when we press any key the programs stops , if you have difficulty in understanding this then remove the “getch();” command and see how the program behaves and then add it again to see what do I mean here





working on more 
pl write to me if you want more elaborate explanation of a topic listed ,
thank you