Sie sind auf Seite 1von 4

4/22/2018 C Constants - C Programming - c4learn.

com


(http://www.c4learn.com/)

Table of Content

 Variables Home (http://www.c4learn.com/index/variables-in-c/)

 C token keywords & identi ers (http://www.c4learn.com/c-programming/c-tokens-keywords-identi ers/)

 C 32 keywords (http://www.c4learn.com/c-programming/c-keywords/)

 C character set (http://www.c4learn.com/c-programming/c-character-set/)

 C variables (http://www.c4learn.com/c-programming/c-variable/)

 C variable naming rules (http://www.c4learn.com/c-programming/c-variable-nameing-rules/)

 C variable attributes (http://www.c4learn.com/c-programming/c-variable-attributes/)

 C variable declaration (http://www.c4learn.com/c-programming/c-declaration/)

 C variable categories (http://www.c4learn.com/c-programming/c-variable-categories/)

 C declaration Vs De nition (http://www.c4learn.com/c-programming/c-declaration-vs-de nition/)

C Constants

 C Constants Home (http://www.c4learn.com/index/constants-in-c/)

 C Constants

 C Constants Types (http://www.c4learn.com/c-programming/c-constants-types/)

 C Integer Constant (http://www.c4learn.com/c-programming/c-integer-constant/)

 C Character Constant (http://www.c4learn.com/c-programming/c-single-character-constant/)

 C String Constant (http://www.c4learn.com/c-programming/c-string-constants/)

 C Escape Sequence (http://www.c4learn.com/c-programming/c-escape-sequence/)

 C Backslash Characters (http://www.c4learn.com/c-programming/c-backslash-characters-meaning/)

C Constants

Ad closed
GST Ready Online Accounting by #1 Accounting Software
- World's
Create GST Invoices. Track Sales, Expenses and Input Tax Credit. Try for Free.
Stop seeing this ad Ads by Google
quickbooksindia.info/GST/Software

 Previous Page (http://www.c4learn.com/c-programming/c-register-storage-class/)


Next Page  (http://www.c4learn.com/c-programming/c-constants-types/)

What is Constant ?
Constant in C means the content whose value does not change at the time of execution of a program.
http://www.c4learn.com/c-programming/c-constants/ 1/4
4/22/2018 C Constants - C Programming - c4learn.com

De nition :
[box]Constant means “Whose value cannot be changed“[/box]

(http://1.bp.blogspot.com/_ynkoLGkpwXY/TDVW8Pa9b1I/AAAAAAAAAjE/JT3pGEVuejQ/s1600/Constant+Variable.jpg)

Explanation :
 Initially 5 is Stored in memory location and name x is given to it
 After We are assigning the new value (3) to the same memory location
 This would Overwrite the earlier value 5 since memory location can hold only one value at a time
 The value of ‘3’,’5′ do not change ,so they are constants
 In Short the ‘Values of Constant Does not Change‘.

Di erent Types of C Constants :

Constant Type of Value Stored

Integer Constant Constant which stores integer value

Floating Constant Constant which stores oat value

Character Constant Constant which stores character value

String Constant Constant which stores string value

How to Declare Constant in C :


We can declare constant using const variable (http://www.c4learn.com/c-programming/c-variable-nameing-rules/).
Suppose we need to declare constant of type integer then we can have following two ways to declare it –

const int a = 1;
int const a = 1;

above declaration is bit confusing but no need to worry, We can start reading these variables from right to left. i.e

Declaration Explanation

const int a = 1; read as “a is an integer which is constant”

int const a = 1; read as “a is a constant integer”

 Previous Page (http://www.c4learn.com/c-programming/c-register-storage-class/)


http://www.c4learn.com/c-programming/c-constants/ 2/4
4/22/2018 C Constants - C Programming - c4learn.com

Next Page  (http://www.c4learn.com/c-programming/c-constants-types/)

Ad closed by
Report this ad

Why this ad?

Custom Search

*T&C Apply
Replay

http://www.c4learn.com/c-programming/c-constants/ 3/4
4/22/2018 C Constants - C Programming - c4learn.com

Ad closed by
Report this ad

Why this ad?

Ad closed by
Report this ad

Why this ad?

© Copyright 2015. All Rights Reserved.

http://www.c4learn.com/c-programming/c-constants/ 4/4

Das könnte Ihnen auch gefallen