JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: c++ language in hindi

literals in c++ , what is literals in c++ language , types , Integer , Floating-point , Boolean in hindi

constant का मतलब होता है fixed value | जिसकी value को प्रोग्राम मे आल्टर नहीं कर सकते है| इसे literals कहते है | constant कोई भी basic
data type जैसे integer और float और character होता है | इसके आधार literals को निन्म भागो मे divide किया जाता है |
मुख्य भाग निन्म है :
1.Integer Numerals
2.Floating-Point Numerals
3.Characters, Strings and Boolean Values
constant को नार्मल variable की तरह use किया जासकता है लेकिन इसकी value को change नहीं किया जासकता है | इसकी value को declare करने के बाद कभी change नहीं किया जासकता है |
Integer Literals
Integer Literals decimal, octal, or hexadecimal constant हो सकता है | prefix keyword से  Integer Literals के type को define किया जाता है  |  जैसे
hexadecimal के लिए  0x or 0X
octal के लिए  0 for octal
decimal के लिए कुश भी use नहीं किया जाता है |
integer literal मे suffix भी हो सकता है | suffix U और L का combination होता है | जैसे
U unsigned integer के लिए use किया जाता है |
L long integer के लिए use किया जाता है |
इन suffix को uppercase और lowercase मे लिखा जा सकता है | को किसी भी order मे हो सकता है |
यहा पर integer literal का उदाहरन निन्म होता है :
213         // valid और integer literals
218u        // valid और unsigned integer literal
0xFaaL      // valid और long integer literal
079         // valid : 9 एक octal digit नहीं है |
032LL      //  valid : suffix को कभी कभी repeat नहीं किया जा सकता है |
Following are other examples of various types of Integer literals −
85         // decimal literals
0213       // octal literals
0x4b       // hexadecimal literals
30         // int
30u        // unsigned int literals
30l        // long literals
30ul       // unsigned long literals
Floating-point Literals
floating-point literal मे एक पार्ट integer पार्ट होता है और दूसरा पार्ट decimal पार्ट होता है जो की decimal के बाद होता है | decimal पार्ट को  fractional part और  exponent part कहते है |   floating-point literal को decimal form और exponential form दोनों मे एक्सप्रेस किया जाता है |
जब  floating-point literal को exponation form मे represent किया जाता है तब दोनों decimal form और exponent form दोनों use किया जाता है | जब floating-point literal को  exponential form मे represent किया है तब integer part, the fractional part को use किया जाता है | लेकिन signed exponation को e और E मे express किया जाता है |
नीचे दिए गये example मे  Floating-point Literals को use किया जाता है :-
3.14159       // valid
314159E-5L    // valid
510E          // Invalid : incomplete exponent
210f          // Invalid : no decimal or exponent
.e55          // Invalid : missing integer or fraction
Boolean Literals
Boolean literals का आउटपुट दो ही होता है :- True and False | और Boolean literals भी दो प्रकार का होता है | जिनका निन्म भाग मुख्य होता है :-
true Boolean literals से true आउटपुट होता है |
False Boolean literals से flase आउटपुट होता है |
True का मतलब ‘1’ नहीं होता है और False का मतलब ‘0’ होता है |
Character Literals
Character literals को single quotes मे क्लोज किया जाता है | अगर Character literals को L से start किया जाता है तब इसका scope wide होता है | और इसे wchar_t type की  variable मे store किया जाता है | इसके अलावा बाकि सभी Character Literals को narrow Character Literals कहते है | और इसे char variable मे store किया जाता है |
Character Literals को plain charecter  , escape sequence (e.g., ‘\t’) और universal character (e.g., ‘\u02C0’) भी हो सकता है |
c++ language मे कुछ charecter के आगे backslash को लगा दिया जाता है तस्ब इस charecter का एक अलग ही मतलब होता है | नीचे इन सभी  Character Literals की लिस्ट नीचे दी गये है :
\\ \ character
\’ ‘ character
\” ” character
\? ? character
\a Alert or bell
\b Backspace Character Literals
\f Form feed Character Literals
\n newline  Character Literals
\r Carriage return Character Literals
\t Horizontal tab Character Literals
\v Vertical tab Character Literals
\ooo Octal number Character Literals जो की octal number को तीन डिजिट मे express किया जाता है |
\xhh . . . Hexadecimal Character Literals जो की hexadecimal को एक या एक से अधिक digits मे explain किया जाता है |
उदहारण 1 :=
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
cout << “Hello\tWorld\n\n Good \n Morning”;
getch ();
}
जब उपर वाला code execute किया जाता है तब इसका आउटपुट निन्म होगा :-
Hello   World  Good   Morning
String Literals
String Literals को double quote मे close किया जाता है | string charecter और  charaecter literals का समूह होता है | charecter literals
plain characters, escape sequences और universal characters होता है |
किसि बहुत बड़ी line को multiple line मे convert किया जाता है जिसके लिए String Literals को use किया जाता है और इन multiple lines को whitespace से sepearate किया जाता है |
नीचे कुछ उदाहरन होते है जिसमे  identical strings के तीन forms निन्म है :-
“hello, Good Morning”
“hello, \
Good Morning”
“hello, ” “Good” “Morning”
Defining Constants
constant को define करने के लिए दो method को use किया जाता है −
Using #define preprocessor.
Using const keyword.
#define Preprocessor
#define Preprocessor से किसी constant को define करने के लिए निन्म syntax को use किया जाता है :-
#define identifier value
यहा पर
identifier : ये constant का नाम होता है |
value : ये constant की value होती है |
उदाहरन 2 :
#include <iostream>
using namespace std;
#define l 10
#define w  5
#define newline  ‘\n’
int main() {
int area;
area = l * w;
cout << area;
cout << newline ;
return 0;
}
जब उपर वाला code execute किया जाता है तब इसका आउटपुट निन्म होगा :-
50
The const Keyword
#define Preprocessor से किसी constant को define करने के लिए निन्म syntax को use किया जाता है :-
#define identifier = value ;
यहा पर
identifier : ये constant का नाम होता है |
value : ये constant की value होती है |
उदाहरन 3 :
#include <iostream>
using namespace std;
int main() {
const int  l = 10;
const int  w  = 5;
const char newline  = ‘\n’;
int area;
area = l * w;
cout << area;
cout << newline ;
return 0;
}
जब उपर वाला code execute किया जाता है तब इसका आउटपुट निन्म होगा :-
50
Sbistudy

Recent Posts

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

18 hours ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

18 hours ago

राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi

sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…

2 days ago

गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi

gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…

2 days ago

Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन

वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…

3 months ago

polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten

get all types and chapters polity notes pdf in hindi for upsc , SSC ,…

3 months ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now