Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Introduction to C
History of C Language
C Variables
Variables Types in C
C Identifiers
C Operators
C Comments
ASCII Value C
Constants C
Features of C
Install C Language
Start C Program
Compilation in c
printf() and scanf()
C Data Types
C Keyword
Format Specifier C
Format Specifier part2
Escape Sequence C
Tokens in C
Boolean in C
What are literals?
 


  

 
Constants C
Question Posted on 25 Aug 2020

Home >> Tutorial >> C Language >> Constants C


Constants C
Constants usually refer to fixed values that program may not be change during its execution. And these fixed value also called literals. And constants can be any of the basic data which types is either integer, floating or character constant. And constant value or variable that we cannot changed in the program. And value can be 50,100,"a",3.4 or "crackyourinterview.com" etc. There are different types of constants in C programming.

List of Constants in C


Constant Value List

Different ways to define Constants in C


There are mainly 2 ways to define constant in C programming.
(1)const keyword
(2)#define preprocessor

(1)const keyword


The const keyword is used to define constant in C programming.
const float PI=3.14;

Now below example is the use of const variable PI


Constant Set Values
Output:-
The value of PI is: 3.140000


Another example which use to change contsant value


Constant Val Change
Output:-
Compile Time Error: Cannot modify a const object



(2)#define preprocessor


The #define preprocessor is also used to define constant.
Syntax:-
#define token value


Constant Define Value
Output:-
3.140000





Other Important Questions
Features of C
Introduction to C
History of C Language
Install C Language
C Variables







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |