Wednesday 8 January 2014

How to Debug a program in C language(Run every line of code )

     

Debugging is most important method while you are dealing with C language. Use of breakpoint,single line execution button is also has its own importance. If you want to be a good developer of C programming you should know how to use debug button in a program.

Here Definition of Debugging. I copied this from one of websites.

"Debugging tools (called debuggers) help identify coding errors at various development stages. Some programming language packages include a facility for checking the code for errors as it is being written."


But main thing is that how to use debug method in a program and how to use watch button in Integrated development environment(Dev C++). Here i am going to introduce debug method with Dev c++ firmware snaps.


1-When you compiled your program and remove all errors then do not click on  run but instead go with debug option. You can see in image debug option available below your program.








2-When you click on debug option two option will enable debug and add watch.








3-Here you perceive one more option ADD WATCH. Using this button you can watch variable values and how those values change during debugging. It helps you to optimize how values changes in a variable. when you click on watch button another window will open,like this.

here is example of how to use watch function.












4- How to use breakpoints.
  breakpoints is another significant part of debugging. Breakpoints used to stop execution process at particular line of your program. This is the best way to find and get rid of errors.
  To use breakpoints you just have to click on numbers which is in left of your program when you click at this point a red round mark will appear. 
    


5- Now click the run button then you will see some more option below your program.initially program will stop at your first breakpoint after that you have option either execute it step by step or run all program.

Tuesday 7 January 2014

5 steps to start C programming with Dev C++ in

1.- download Dev C++ software from here click to download Dev C++   when you download and install Dev C ++ IDE on your computer or Laptop then double click the Dev C icon appear on Computer Desktop. You will see a window will open.

2.-People always start with new file but that is not a correct way to start particularly for beginner. Begin with to  choose a  new project. Here i the snap shot example.
    Go with this hierarchy
 File menu 
                  > New 
                              > Project 






3- When you choose project option then a new window will open then select console application option and after select console application below Enter project name. Its depend upon programmer which name He/She want and select C programing option project between C and C++.














4- When you complete this process click OK button and Save your project in proper location. When you finish this in your dev C++ window there is project option window click on that project option it consist two option test(its your project name) and main.c file. Programmer can write his/her code in this file.













5- Here your workspace now you write  your code or program here and compile  and run it.After that you can see output of your program.

Monday 6 January 2014

First program in C

/* First C program  this line is a comment dont take part in programme */

#include<stdio.h>

int main(void)
  {
     printf("Welcome to C world !") ;
     return 0 ;
  } //end of main

Here your output in black screen
---------------------------------------------------------------------------------
Welcome to C world !
---------------------------------------------------------------------------------

Common Programming Error:-

How to start C programming as beginner and Do's and dont's for C beginner

       When someone imagine to learn C programming he or she thinks its very simple we have to go market and purchase  best book for C programming and start reading. After buying book thought comes in mind " hurry hurry ! finally we did " and we initiate very good step but after few days their book found a corner place because they feel boredom and lost their interest on that book .
       Before start learning C language you have to learn where we write these C programmed and how to Run,debug and execute it. We have to first learn about IDE(integrated development environment).
       Here i am listing few IDE where you can write C program and can see the output

1.- Dev C++ (best for beginner)
2.- Codeblocks
3.- Ecilipse (Best but for professional)

      If you want to download one of these IDE so you have to little googling or you can go with below links

Click here to download Dev C++

Click here to download Ecilipse IDE

Click here to download Codeblock IDE

In my next post we will discuss how to fun with C

Compiler for C,C++ and Python {paste your programme to see the output}