Constants in C Hindi |const keyword in C in Hindi 2022

Hello, friends  C programming language सिखने की सीरीज में आज const keyword और Constants in C Hindi |const keyword in C in Hindi 2022 के बारे में पढ़ेंगे। friends Hindi me IT में आपका बहुत बहुत अभिनान्दन हैं.

what is Constants in C Hindi – Constants क्या हैं C प्रोग्रामिंग लैंग्वेज में

const को जानने से पहले Constants और variable का हिंदी मीनिंग समझते हैं। Constants का हिंदी मीनिंग स्थिरांक होता हैं। जिसे change नहीं किया जा सकता हैं। वहीं variable का हिंदी मीनिंग चर यानी की जिसे change किया जा सकता हैं।

computer की memory में डाटा स्टोर करने से पहले मेमोरी में उस लोकेशंस का नाम देना होता हैं जहाँ हमें डाटा store करना होता हैं।  इन नाम को हम variable या Constants कहते हैं।

C programming Language में हम Constants variable दो प्रकार से declare कर सकते हैं।

  1. Using const keyword
  2. Using #define preprocessor

const keyword in C in Hindi

what is const keyword in C in Hindi ( const keyword क्या हैं C लैंग्वेज में )

C programming language में const एक keyword हैं. जिसे qualifier कहते हैं. const कोई data type नहीं हैं।

const keyword जिस data declaration के साथ लग जाता हैं।  उससे बनाने वाले variable की प्रॉपर्टी को change कर देता हैं। क्या प्रॉपर्टी change करता हैं। जिस variable को const keyword के साथ declare किया गया हैं उस variable की  value में कोई change नहीं कर सकते हैं।

यानी की const keyword के साथ variable declare किया गया हैं उसकी value Constant हो जाती हैं। उसकी value वही रहेगी जब const को  declare करते समय value दी थी।

Syntex :

const data_type constant_Name = Value;

const keyword को एक example से समझते हैं।

example 1:-

#include<stdio.h>

int main() {
  int x = 5;
  x++;
 printf("x = %d", x);
}

इस example में हमनें एक variable int data type के साथ declare किया हैं। और आगे हमनें x value को increment कर दिया हैं।  जिसे x की value 5 से बढ़कर 6 हो जाएगी और output 6 print होगा स्क्रीन पर क्योकिं एक नार्मल variable की value को C program में कितनी भी बार चेंज किया जा सकता हैं। क्योकिं variable प्रॉपर्टी चेंज की जा सकती हैं।

Output:-

6

example 2:-

#include<stdio.h>

int main() {
  const int x = 5;
  x++;
 printf("x = %d", x);
}

इस example 2 में हमनें एक variable const keyword और int data type के साथ declare किया हैं। और आगे हमनें x value को increment कर दिया हैं।  इस प्रोग्राम में अब error आयेंगी क्योकिं const keyword के साथ declare variable की value change नहीं कर सकते हैं। और output में error दिखेगी।

Compile Time Error: assignment of read-only variable 'x'

Using #define preprocessor in C in Hindi

C programming language में Constants को #define preprocessor  का use करके भी declare कर सकते हैं। अगर हम #define preprocessor का use करके Constants declare करते हैं तो हमको स्टेटमेंट के लास्ट में semicolon (;) लगाने की जरूरत नहीं होती हैं.

#define preprocessor  का use करके भी declare कर सकते हैं को Constants को कम्पुयटर मेमोरी में मेमोरी allocate नहीं होती हैं। क्योकिं preprocessor directive होने की बजह से program compile होने से पहले ही const को value assign हो जाती हैं।

Example:-

#include <stdio.h> 
#define MIN(a,b) ((a)<(b)?(a):(b))
void main() {
printf("Minimum between 10 and 20 is: %d\n", MIN(10,20));
}

Output :-

Minimum between 10 and 20 is: 10

Constants के प्रकार C programming Language (Types of Constants in C in Hindi)

  • Integer constants
  • Real or Floating-point constants
  • Octal & Hexadecimal constants
  • Character constants
  • String constants
  • Backslash character constants
Constant type data type (Example)
Integer constants int (43, 862, -678 etc )
Real or Floating point constants float (15.456789)
Octal constant 021, 033, 046 etc.
Hexadecimal constant 0x2a, 0x7b, 0xaa etc.
Character constants ‘a’, ‘b’, ‘x’ etc.
String constants “Hindi me IT”, “Shreekant Singh”

By reference :- https://www.geeksforgeeks.org/const-qualifier-in-c/

आशा  करता हूँ Constants in C Hindi |const keyword in C in Hindi 2022 आपको पसंद आई होगी. अगर आपको इससे related कोई question पूछना हैं तो आप comment करके पूछ सकते है. अगर हमारे व्दारा की जानकर अच्छी लगी हो तो आपने दोस्तों के साथ जरुर शेयर करें. धन्यबाद

Constants क्या हैं C प्रोग्रामिंग लैंग्वेज ?

const keyword in C in Hindi

const को जानने से पहले Constants और variable का हिंदी मीनिंग समझते हैं। Constants का हिंदी मीनिंग स्थिरांक होता हैं। जिसे change नहीं किया जा सकता हैं। वहीं variable का हिंदी मीनिंग चर यानी की जिसे change किया जा सकता हैं।

Related Posts

Leave a Comment