" C "
Brian Kernighan and Dennis Ritchie never even thought that their daughter would revolutionize the entire world. They just tried to give birth to a simple and multitasking beauty which will help them to carry out their desired task in their operating system "Unix" .But " C" charmed tech people in such a way that not only they fell for her but also got addicted to her a lot.
The reason "C" became so popular because its simple , reliable and easy to use as well as understand. Many will think that "C" is soooooo outdate so why should i bother learning "C" ? , instead i will go with "Java" or "Dot Net" !!! . But what i think differs from it a lot and soon you will know why I think like that.
1) Nobody can learn "Java / Dot Net " without learning "C". Because those languages contains many essential but mighty powerful things like "Classes " , "Inheritance" , "Polymorphism" , "Encapsulation / Abstraction " etc .......... So learning these things without getting thorough with the simple basic concepts is like " putting Cart before Horse ". So one should start from charming gal that is "C" and move ahead to matured ladies. ;D
2)Many people may not know this but most of the part of the popular Operating Systems like " Windows " ," Unix " are still made from "C" , since the execution speed or the speed at which "C" carries out the tasks is unbeatable not even by "Java" or "Dot Net".
3)Also devices which have become part of our life that is Cellphones , Palmtops or even food processor , Oven ( you can add washing machine in this list tooo :P ) are working on the small microprocessor i.e. an OS and program embedded in small chip are working due to "C".
4)One more thing of Great Interest is "GAMES" . The objects navigated by user for example .. a bot or a spaceship ..... what if it takes tooooooo long to move ???? ..........you will get bored right ?? .. these things are also Created ( written ) using "C" programming.
Thats why IT people who were loving womens like "Pascal" , "Fortran" , ended up marrying to "C".(Just Like me :P ^^)
So Lets start learning more about "C". Shall we ??
Getting to Know the Supergal " C " :-
If you know English Language you can easily learn " C ". because There is close analogy between learning English and Learning " C ". In english we learn "Alphabets then words and then Sentences" . The same thing happens in " C ". You can get an idea of it from the diagram below......
So let move ahead .........
C : The Character Set
A diagramatic representation is always better ... dont you think ??? .... here you go !!!!!!
These are the characters which are allowed for extensive use in "C" .
Constant , Variables and very important "Keywords"
"Constant" as its meaning suggests is a Constant or we can call it never changing ............opposite of "Variable" .
Constant is an entity that never changes where as variable is an entity that may change. Just like human memory , memory of computer is made up of millions of small parts , lets call them memory cells !!
These memory cells can hold many values. If the values stored at one memory cell cannot be changed then that value is constant and if it can be overwritten then that value is variable.
Type Of " C " Constants :
C constants are divided into 2 major categories :
1) Primary Constant
2) Secondary Constant
Lets see the diagram again ......
Since we are at a beginners level ............ lets stay beginner for the time being ........we will study only the Integer , real , Character Constant for now.
Rules for Integer Constants
(a) An integer constant must have at least one digit.
(b) It must not have a decimal point.
(c) It can be either positive or negative.
(d) If no sign precedes an integer constant it is assumed to be positive.
(e) No commas or blanks are allowed within an integer constant.
(f) The allowable range for integer constants is -32768 to 32767. ( Actually the range for the integer is dependent on the compiler. For 32 bit compiler , integer has even higher range. To know about compiler
please click what compilers ??? )
Ex. 123 , 321 , +768 , +911111 etc
Rules for Constructing Real Constants
Real constants are often called Floating Point constants. The real constants could be written in two forms—Fractional form and Exponential form.
Following rules must be observed while constructing real constants expressed in fractional form:
(a) A real constant must have at least one digit.
(b) It must have a decimal point.
(c) It could be either positive or negative.
(d) Default sign is positive.
(e) No commas or blanks are allowed within a real constant.
ex. 123.43 , +2434.33 , -12222.22 , -45823. 034 etc.
We can also use Exponential Constants. These are only used if the value is very very small or very very large.
They are not different from the Real Constants but very useful.
In exponential form of representation, the real constant is represented in two parts. The part appearing before ‘e’ is called mantissa, whereas the part following ‘e’ is called exponent.
Following rules must be observed while constructing real constants expressed in exponential form:
(a) The mantissa part and the exponential part should be separated by a letter e.
(b) The mantissa part may have a positive or negative sign.
(c) Default sign of mantissa part is positive.
(d) The exponent must have at least one digit, which must be a positive or negative integer. Default sign is positive.
(e) Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.
Ex.: +3.2e-5 , 4.1e8 ,-0.2e+3,-3.2e-5 etc.
and Last one but also equally important ......
Rules for Constructing Character Constants
(a) A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. Both the inverted commas should point to the left. For example, ’A’ is a valid character constant whereas ‘A’ is not.
(b) The maximum length of a character constant can be 1 character.
Ex.: 'A' , 'I','5','=' etc
This is for now folks .............. we will see "Variables" next time ........... now after such a hard , brainracking reading there should be li'l fun right ??? ..... so here you go ...........
Constant , Variables and very important "Keywords"
"Constant" as its meaning suggests is a Constant or we can call it never changing ............opposite of "Variable" .
Constant is an entity that never changes where as variable is an entity that may change. Just like human memory , memory of computer is made up of millions of small parts , lets call them memory cells !!
These memory cells can hold many values. If the values stored at one memory cell cannot be changed then that value is constant and if it can be overwritten then that value is variable.
Type Of " C " Constants :
C constants are divided into 2 major categories :
1) Primary Constant
2) Secondary Constant
Lets see the diagram again ......
Since we are at a beginners level ............ lets stay beginner for the time being ........we will study only the Integer , real , Character Constant for now.
Rules for Integer Constants
(a) An integer constant must have at least one digit.
(b) It must not have a decimal point.
(c) It can be either positive or negative.
(d) If no sign precedes an integer constant it is assumed to be positive.
(e) No commas or blanks are allowed within an integer constant.
(f) The allowable range for integer constants is -32768 to 32767. ( Actually the range for the integer is dependent on the compiler. For 32 bit compiler , integer has even higher range. To know about compiler
please click what compilers ??? )
Ex. 123 , 321 , +768 , +911111 etc
Rules for Constructing Real Constants
Real constants are often called Floating Point constants. The real constants could be written in two forms—Fractional form and Exponential form.
Following rules must be observed while constructing real constants expressed in fractional form:
(a) A real constant must have at least one digit.
(b) It must have a decimal point.
(c) It could be either positive or negative.
(d) Default sign is positive.
(e) No commas or blanks are allowed within a real constant.
ex. 123.43 , +2434.33 , -12222.22 , -45823. 034 etc.
We can also use Exponential Constants. These are only used if the value is very very small or very very large.
They are not different from the Real Constants but very useful.
In exponential form of representation, the real constant is represented in two parts. The part appearing before ‘e’ is called mantissa, whereas the part following ‘e’ is called exponent.
Following rules must be observed while constructing real constants expressed in exponential form:
(a) The mantissa part and the exponential part should be separated by a letter e.
(b) The mantissa part may have a positive or negative sign.
(c) Default sign of mantissa part is positive.
(d) The exponent must have at least one digit, which must be a positive or negative integer. Default sign is positive.
(e) Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.
Ex.: +3.2e-5 , 4.1e8 ,-0.2e+3,-3.2e-5 etc.
and Last one but also equally important ......
Rules for Constructing Character Constants
(a) A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. Both the inverted commas should point to the left. For example, ’A’ is a valid character constant whereas ‘A’ is not.
(b) The maximum length of a character constant can be 1 character.
Ex.: 'A' , 'I','5','=' etc
This is for now folks .............. we will see "Variables" next time ........... now after such a hard , brainracking reading there should be li'l fun right ??? ..... so here you go ...........




Very nice one.
ReplyDeleteThank You.
Great tutorial with example. Superb
ReplyDeleteThanks, Merient Infotech