JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: c++ language in hindi

C++ : Program Header , Function Header , Manipulator , Newline character , C++ Source code Formatting

Newline character , C++ Source code Formatting , C++ : Program Header , Function Header , Manipulator :-
इससे पहले के article मे , comment , function definition और preprocessor को discuss किया था |अब इस article मे c++ प्रोग्राम के बाकि elements को discuss करेगे |
Function Header
जब किसी c++ प्रोग्राम function को run किया जाता है या दुसरे function द्वारा call किया जाता है तब function header इन दोनों functions के बीच interface को define करता है |इसमें function name को define करता है जिसमे function के type और function के नाम को define करता है |इसमें function के flow को भी define करता है |function definition मे () मे function के parameter को pass करते है |argument और parameter लिस्ट call function से calling function मे data के फ्लो को define करता है |
function definition मे main() function मे अलग होता है | main() function किसी प्रोग्राम का start code होता है |जो की complier को प्रोग्राम को start होने का निर्देश देता है |
उदाहरण के लिए :
main() के लिए , int जो की main() function के start मे होता है | वो ये define करता है की function से integer type return होती है |अगर main() function  से कोई data return नहीं होता तब इसका type void कहते है |
function का नाम main() क्यों होता है |
जब हम निन्म उदहारण को consider करे तो
#include<iostream>
void main()
{
using namespace std;
cout<< “Good Morning”;
getch();
}
इस उदाहरण मे , जब code को compile करते है तब प्रोग्राम मे main() function का होना आवश्कता है |लेकिन MAIN () और Main () function तब compiler  error message देगा |किसी प्रोग्राम मे , केवल एक main() function की जरुरत होती है |
जब किसी प्रोग्राम को compile किया जाता है , complication main() से start होता है |अगर प्रोग्राम मे , main() function नहीं होता तो प्रोग्राम अधुरा होता है |और compile नहीं होता है |
windows मे dynamic link library को use किया जाता है जिसमे main() function को use नहीं करना होता है |इसका उदाहराण मे किसी रोबोट्स , controller चिप के लिए प्रोग्राम |
Manipulator
cout<< end1;
इस statement को Manipulator कहते है |जो की किसी नए statement के start होने के लिए define कियाजाता है |जब किसी आउटपुट statement मे , end1 को introduce करते है तब couser console screen पर नए line पर shift हो जाता है |endl , cout की तरह iostream header file का पार्ट होती है | इसलिए इसके लिए namespace को use किया जाता है |
cout function से next line मे automatic नहीं जा सकता है |इसे केवल string को print करने के लिए किया जाता है|
उदहारण के लिए :
#include<iostream>
void main()
{
using namespace std;
cout<< “Good Morning !”;
cout<< “Parth”;
cout << endl;
cout << “It is my First Program.”;
getch();
}
आउटपुट होता है :
Good Morning ! Parth
It is my First Program.
इस उदाहरण मे , Good Morning ! और Parth को एक ही line मे print होता है |और endl से cusor next line मे shift हो जाता है | उसके बाद It is my First Program. को print होता है |
Newline character
c++ मे endl के अलावा एक option होता है नए line मे shift करने के लिए | इसे new line operator (\n) कहते है |ये दो single character से मिलकर बना होता है |जिसे new line operator कहते है |
अगर किसी string को display करना होता है तब new line option से कम character को type करना होता है |इसका उदहारण है :-
#include<iostream>
void main()
{
using namespace std;
cout<< “Good Morning !”;
cout<< “Parth”;
cout << endl;
cout << “It is my First Program.”;
getch();
}
इस उदाहरन मे , endl को use किया गया है |जबकि निन्म उदहारण मे ,
#include<iostream>
void main()
{
using namespace std;
cout<< “Good Morning !”;
cout<< “Parth \n”;
cout << “It is my First Program.”;
getch();
}
दोनों प्रोग्राम से सामान आउटपुट मिलता है लेकिन कम character को type करना होता है |
C++ Source code Formatting
कुछ language जैसे prascal , fortan ,c language मे एक statement को एक line मे लिखा जाता है | इस सभी language मे , return statement को अलग से लिखना होता है |लेकिन c++ मे , return statement को अलग से लिखना complusy नहीं होता है |return statement को प्रोग्राम के free space मे कही पर भी लिख सकते है |उदाहरण के लिए :-
int main()
{
using
namespace std;
cout<<“good mornging “<<
endl; cout<<
“I am Parth”<<endl; return;
}
उपर लिखा गया code compile सही होगा कोई भी error नहीं आएगी लेकिन इससे समजने मे काफी difficulty होगी |अतः c++ मे ,कुछ rules को फॉलो करना होता है |जिससे code का display अच्छा लगे |और standard पर follow हो |
1.किसी भी syntax मे space नहीं हो सकता है |जैसे
main() ; // right syntax
ma in (); // invalid syntax
2.return statement को code के बीच कम कम लिखना चाहिए |
3.इसके अलावा कई सारे rules होते जो बाद मे discuss करेगे |


Token और whitespace
टोकन एसे element होते है जिसे divide नहीं किया जा सकता है |किसी एक टोकन को दुसरे टोकन से अपके से अलग कर सकते है |इस format को white space कहते है |उदहारण के लिए () , (,) , “” आदि tokens है जिसे white space के साथ use नहीं कर सकते है |
उदाहरण के लिए :
return0;   // invalid statement
return (0) ; // valid statement , 0 will be return
return(0);  // valid statement , 0 will be return
intmain() ; //invalid statement
int main() ; //valid statement , program start
int main( ) ;  //valid statement , program start
Sbistudy

Recent Posts

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

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

13 hours ago

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

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

13 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