C - Constants in Hindi




एक constant एक value या variable है जिसे प्रोग्राम में बदला नहीं जा सकता है, उदाहरण के लिए: 10, 30, 'a', 3.4, "सी प्रोग्रामिंग" इत्यादि C प्रोग्रामिंग में विभिन्न प्रकार के constant होते हैं।

Constants एक variable की तरह होते हैं, बस इनमे इतना सा फर्क होता है, उनके मूल्य कभी परिभाषित होने के दौरान execution के दौरान कभी नहीं बदलते हैं।

सी Constants सी प्रोग्रामिंग भाषा का सबसे fundamental और आवश्यक हिस्सा है। C में constant निश्चित मान हैं जो किसी प्रोग्राम में उपयोग किए जाते हैं, और इसका मूल्य प्रोग्राम के पूरे execution के दौरान समान रहता है।

  • Constants को शाब्दिक भी कहा जाता है।

  • Constants डेटा प्रकारों में से कोई भी हो सकता है।

  • इसे केवल upper-case नामों का उपयोग करके constants को परिभाषित करने के लिए सबसे अच्छा अभ्यास माना जाता है।

List of Constants in C

For Example
Constant Example
Decimal Constant 10, 20, 450 etc.
Real or Floating-point Constant 10.3, 20.2, 450.6 etc.
Octal Constant int (Example: 013 /*starts with 0 */)
Hexadecimal Constant int (Example: 0x90 /*starts with 0x*/)
Character Constants char (Example: ‘A’, ‘B’, ‘C’)
String Constant "c", "c program", "c in htmltpoint" etc.

Syntax:

const type constant_name;

Example

#include 
void main()
{
const int height = 100; /*int constant*/
const float number = 4.14; /*Real constant*/
const char letter = 'A'; /*char constant*/
const char letter_sequence[10] = "ABC"; /*string constant*/
const char backslash_char = '\?'; /*special char cnst*/
printf("value of height :%d \n", height );
printf("value of number : %f \n", number );
printf("value of letter : %c \n", letter );
printf("value of letter_sequence : %s \n", letter_sequence);
printf("value of backslash_char : %c \n", backslash_char);
}

Result

value of height : 100
value of number : 4.140000
value of letter : A
value of letter_sequence : ABC
value of backslash_char : ?

Constant Types in C

दोस्तों स्थिरांक को दो basic types में वर्गीकृत किया जाता है, और इनमें प्रत्येक types के subtypes categories होती हैं।

  • Numeric Constants

  • Character Constants