Overview of Constants and Variables of C Language

 c constants

CONSTANTS:
The quantity which does not change during the execution of program is called constant.




     'C' CONSTANTS: 2 TYPES
  • Numeric constants
  • Non numeric constants
     NUMERIC CONSTANTS: 2 TYPES
  • Integer constant
  • Floating point constants
     NON NUMERIC CONSTANTS: 2 TYPES     
  • Character constants
  • String constants







INTEGER CONSTANTS:
An integer constant is a sequence of digits without decimal point means whole number. It is prefixed with a plus or minus sign.The syntax of integer constant is


   Sign       Digits  

where
Sign => optional Plus sign for positive number and minus sign for negative number
Digits => sequence of digits

EXAMPLE:
500 , -23 , +56 etc.




FLOATING POINT CONSTANT:
A floating point constant is a sequence of digit with decimal point means real number. It is prefixed with plus or minus sign.The syntx of floating point constant is



  Sign    Integer part    Decimal point    fractional part 

where
Sign => optional plus or minus sign
Integer part => digits before decimal point
Decimal point => dot symbol
fractional part => digits after decimal point

EXAMPLE:
+2.4 , -55.64 , 52.0 , 88.57 etc.

CHARACTER CONSTANT:
A single character constant is a single character enclosed with in pair of apostrophes.
EXAMPLE: 'c' , ' '(blank character) , '#' etc.

STRING CONSTANT:
A string constant is a combination of character enclosed with in a pair of double quotes
EXAMPLE: " hi" , "200" etc.


VARIABLES:
The quantity that changes during the execution of program is called variable. The variable represent a particular memory location where the data can be stored. Variables are also called Identifiers.
EXAMPLE:
name , sum , average , age , state etc.

DECLARATION OF VARIABLES:
All variables must be declared before they are used in the program. The purpose of declaring variables is to reserve the memory require for the variables. The declaration is done in the declaration part of C program.The syntax for declaring variable is



  Data_Type     Varlist     Semicolon 
where 
Data_Type => such as int, float, char etc.
Varlist => one or more variable
Semicolon => shows termination of declaration

EXAMPLE:
int abcd; int x;
float marks;
char a;
char name[10];

ASSIGNING VALUES TO VARIABLES:
As we all know variables represent some memory location, where the data is stored. Each variable is associated with one or more values. The process of giving values to variables is known as assignment of values. The assignment operator"=" is used to assign a value to a variable. its syntax is



 Variable_Name   =   value   ; 
where
Variable_Name => represents memory location where value is stored
value => constant or variable

EXAMPLE:
1. m=10;
2. int x=100;

0 Response to "Overview of Constants and Variables of C Language"

Post a Comment

Popular Posts

Label

1 Sidebar 2 Columns 3 Columns Footer 3rdball 4 Columns Footer Alex Alvaro Antsasia Arlinadesign Averie Barry BASIC CONCEPTS Basil Bayna Fast BeautyPress BeautyTemplates Beckel Best Best - Clean Beyonce Pro BioMag BlackMag Blanter Nova Blogger Card Bloggertheme9 Blogish Bpress Brakt C LANGUAGE C PROGRAMS C++ LANGUAGE C++ PROGRAMS Carella Cellar Charlotte Chooko Lite Clara Clean Combo One Cooperate Crusade Darry Dorman Dreamway Dunia Blanter eCars EduAcademy EducationPress Elise Elvan Eva Everyday FabNews Fashion Fashion Blogger Template Fashion Gossip FastCars Fedo FlashNews Fredy Portfolio Gaming Globus GoodTime Goomsite HTML LANGUAGE iGaming Indicate Innove Insomnia InspiredNews iSoft Jasmine Kalem Landscaping Lashira Lavelle Lily Fashion Limax Linea Lionex Luminescence Lite Lumix Luxury Magazine MagazinePro MAJOR DIFFERENCES MarketingBlog Martin MaxiMag Medica Mega Melissa Mercury MeshMag Minimag Minimalist MiniNews MovieKhor msdesignbd MusicLand Neko NetZine New Spread News16 Newsflash NewsForce NewsIdea Newspaper News NewsPro Nubie Fast Odd Themes Optima PaperMag PaperMag blog Parhlo Perfection Personal Personal Blog Photosout PixelZ Power Blog Premium Themes ProfileMag Purez Rano ReadNews Real estate Remito Grid Responsive Revo Robusta Rotario Saara SeoBoost Settle Shouters Simple Catch SimpleClean Sketchly SNews SolidMag Someo Sophie Sora Sora Bank Sora Home Sora News Responsive Sora One Sora Ribbon Spido Sticko Stucco Sure Mag Swift Tech Tech Pro Techia Techmax TechSpot TemplateClue Templateism Templatesilk Templatesyard Templatezy The Freelancer TheBlogger TheFocus Themeforest Themexpose TIPS AND TRICKS Topside TravelMag Trendy Trendy Travel Tumblr Under Construction Uong Jowo Veethemes Vertox VideoPlay Vigo Waverly way2themes WebBiz Wedding X-Mag Zealer ZetaMag