Recent Posts

Friday 22 December 2017

What is constant in C

In the previous post we have learn about keywords. In this post we will learn about What is Constant they are also part of syntax.

Constants

Constant is a value that doesn't change during program execution.Constants are the fixed values.fixed values are also referred as literals.The alphabets,numbers and special symbols when properly combined they forms constants,variable and keywords.Value is stored in memory at free location.
To declare a constant use const keyword

For example (5*a) 
     In the above example 5 is a constant and 'a' is a variable whose value change during program execution.


Types of constants

Constants are divided into two types as:

1)Primary constants:

     C compiler already know the meaning of Primary constants.In C primary constants are three types as 

1) Integer constant : 

Rules for constructing Integer constants.
1) It should not have a decimal point.
2) An integer constant should have one digit.
3) It can be positive or negative.
4) If no sign precedes as integer constant it is suppose to be positive.
5) No commas or blanks are allowed within an integer constant.
6) The integer constant allowable range is -32768  to +32767.

2) Real constant :
Rules for constructing Real constants
Real constants are also called as floating point constants.The real constants should be written in two forms as Fractional form and Exponential form.

Following rules should be observed where as constructing real constants expressed in fractional form.
It should have a decimal point.
A Real constant should have one digit.
It can be positive or negative
Default sign is positive.
No commas or blanks are allowed within a Real constant
Example :  
+15.54
 29.0
-321.58

            The exponential type representation of real constants is typically used if the value of the constant is too small or too large.It but doesn't limit us in any way from using exponential form of representation for other real constants.

In exponential type of representation,the real constant is represented two parts.The part appearing before 'e' is called mantissa, whereas the part following 'e' is called exponent.   
  • Character constant 

2)Secondary constants

The definition of secondary constants is defined by the programmer.







0 comments:

Post a Comment

Followers

Popular Posts

Categories

social media

Text Widget

Powered by Blogger.

About Me

My name is junaid khan and i am a full time blogger and author of a blog tutorial called tutorialpointsolution.

String function

In the previous post we learn about what is String .we know that string is a collection of two or more characters.In string we can store al...

Search This Blog

Technology

Adbox

Recent Post

Breaking

Recent In Internet

Comments

Facebook

Pages

Comments

Pages

Recent

Pages

Technology