Keywords and  Constant

Keywords and  Constant

Keywords

Keywords ऐसे Words हैं जिनका C Compiler के लिए Special Meaning है। Translation Phases 7 और 8 में, एक Identifier की Spelling और Case, C Keyword के समान नहीं हो सकते हैं |
C Programming में, 32 keywords होते  हैं, जिनके Predefined Meaning हैं और इन्हें एक Variable Name के रूप में Use नहीं किया जा सकता है। इन Words को “Reserved keywords ” के Form में भी जाना जाता है।

These Keywords are 

     auto    int struct double
     break              long switch else
     case              register typedef enum
     char              return union entern
     const              short unsigned float
     continue              signed void for
     default              size of volatile goto
     do              static while if

 

Constant

Constant Fixed Value को Refer करता है जो Program Execution के दौरान Alter नहीं हो सकता है। इन Fixed Values को literals भी कहा जाता है। Constants किसी भी Basic Data Types के हो सकते हैं | जैसे – Integer constant, floating constant, character constant, या string literals। enumeration constant भी हैं। Constant को Regular Language की तरह ही माना जाता है इनके Values को Definition के बाद Modified नहीं किया जा सकता है।

Integer literals

एक integer Literals , Octal, या Hexadecimal Constant हो सकता है। Base or Radix या Prefix को Specifies करता है, Hexadecimal के लिए 0x या 0X, Octal के लिए 0, और Decimal के लिए कुछ भी नहीं।एक integer literals में एक Suffix भी हो सकता है जो क्रमशः Unsigned और Long Time के लिए ‘U’ और ‘L’ का Union होता है। Suffix Uppercase या Lowercase हो सकता है और किसी भी Order में हो सकता है।Example

222 /* Legal */
216u /* Legal */
0xFeeL /* Legal */
068 /* Illegal: 8 is not an octal digit */
012UU /* Illegal: cannot repeat a suffix */

floating Literals

Floating-Point integer में एक integer part, एक decimal point, एक Fraction Part और एक Exponent Part होता है। आप Floating Point Literals को Decimal Point Form या Exponential Part में Expressed कर सकते हैं। Decimal Form को Represent करते समय, आपको Decimal Point, Exponential या दोनों को Include करना चाहिए; और Exponential Form का Representation करते समय, आपको Integer part, And Fraction Part या दोनों को शामिल करना चाहिए। यह Signed Exponent ‘E’ या ‘e’ द्वारा Introduced किया जाता है।
Example

3.14139 /* Legal */
3149E-5L /* Legal */
520E /* Illegal: incomplete exponent */
230f /* Illegal: no decimal or exponent */
.e65 /* Illegal: missing integer or fraction */

Character Constants

Character Literals Single quotes में Enclosed कर देते हैं, Example के लिए, ‘x’ को 4 Type के एक Single variable में store किया जा सकता है। एक Character Literals एक Plane Character (जैसे, ‘x’), एक escape sequence (जैसे, ‘\t’), या एक Universal Character (जैसे, ‘\u02C0’) हो सकता है। C Programming में कुछ Character हैं जो Backslash से पहले Special Meaning का Represent करते हैं, Example के लिए, Newline (\ n) या Tab (\ t).

Example

#include <stdio.h>

int main() {
printf("Hello\tWorld\n\n");

return 0;
}

String Literals

String Character या Constant double quotes “” में Enclosed हैं। एक String में ऐसे Character होते हैं जो String Character, Character literals के समान होते हैं: Plain Character, escape sequence, और Universal Character। String Literals का Use करके एक Long Line को कई Lines में Break कर सकते हैं और White space का उपयोग करके उन्हें Separate कर सकते हैं।

Example

"hello, world"

"hello, \

world"

"hello, " "w" "orld"

Love Babbar SDE Sheet Problems – Video Solution in hindi

Defining Constant

C Programming में constant को दो प्रकार से Define कर सकते हैं –

1. Using #define preprocessor

निचे दिए गए Form में हम #define preprocessor Use कर सकते है।

# define identifier value

Example

#include <stdio.h>

#define LENGTH 10
#define WIDTH 5
#define NEWLINE '\n'

int main() {
int area;

area = LENGTH * WIDTH;
printf("value of area : %d", area);
printf("%c", NEWLINE);

return 0;
}

Output :

value of area : 50
what is React Native in hindi
2. The const Keyword

आप निम्न प्रकार से एक Specific Type के साथ Constant Declare करने के लिए Cons Prefix का Use कर सकते हैं

const type variable = value;
#include <stdio.h>
int main() {
const int LENGTH = 10;
const int WIDTH = 5;
const char NEWLINE = '\n';
int area; 

area = LENGTH * WIDTH;
printf("value of area : %d", area);
printf("%c", NEWLINE);

return 0;
}

Output :

value of area : 50
Previous articleVariables and Data Types
Next articleI/O Statement & Assignment Statement

LEAVE A REPLY

Please enter your comment!
Please enter your name here