The idea of programming might sound like a frightening task, but don’t worry. We designed this blog so that you can get your feet wet without stepping into the deeper complexities of the programming.
This Blog is dedicated to all those people who want to learn the most basic but important Programming Language'C Programming'.
If done step wise C language is easy and fun to learn.
So lets get started.
Start reading from the First Post to understand C programming.You may read a desired topic from the labels.
Press Ctrl+D to add this page to your Favourites/Bookmarks for further reference.
Note:Your comments,queries and suggestions are welcome.Feel free to post them in the the comment boxes available after every post.

Search C Programs,Compilers,etc.

Saturday, May 17, 2008

Using symbolic Constants(#define)

Using Symbolic constants(#define)


While developing a program in C language,we often use certain unique constants in a program.These const. may appear repeatedly in a C program,at number of places.
Foe example,if we want to calculate the area of n number of circles,we require a constant 3.14 which is the value of'pi'.
Now we may like to change the value of pi from 3.14 to 3.14159.To achieve this we will have to search through-out the program and explicitly change the value of pi whereever it has been used.If any value is left unchanged the program will produce wrong results.When we use variable ,value may change accidently,which results to wrong output.
To avoid these type of mistakes w use symbolic constants in our C program.
the syntax of a symbolic constant is;

#define symbolic name value


e.g.
#define pi 3.14159
#define total 100

0 comments: