हिंदी माध्यम नोट्स
Categories: c++ language in hindi
C++ : Program Format in programming language in hindi , c++ program format in hindi
c++ program format in hindi , C++ : Program Format in programming language in hindi :-
जब c++ मे किसी function को बनाते है प्रोग्राम को major parts मे डिवाइड किया जाता है और इन function को design किया जाता है |इसमें निन्म sections होता है :-
1.Comments जो की // prefix से indicate होता है |
2. Pre processor जो की #include से मेंशन होता है |
3.Function header : int main()
4.Namespace directive
5.A function body
6.Statements जो की output statement को perform करते है |
7.A return statement
इसके अलावा main() function को निन्म प्रकार से define करते है |
int main()
{
statement;
return 0;
}
इस उदहारण मे , function का नाम main() है जिसका return type integer है |इससे function definition कहते है | function definition के दो भाग होते है :-
1.int main() : इससे function header कहते है | या इसे function interface कहते है |ये प्रोसेस define करते है जो इस function को बाकि के function से लिंक को declare करता है |
2.function body : इसे {} से क्लोज होते है | जो की function के statements को define करता है |इस body मे , एक complete instruction को statement कहते है |इस statement को semicolon से terminate करते है |
C++ Program Format |
Statement
एक statement , एक complete instruction को define करता है |अगर किसी source code को run करते है तब compiler एक statement को perform करने के बाद दूसरा statement perform होता है |इन दोनों स्त्स्तेमेंट को किसी प्रकार के syntax से differentiate करते है |जैसे
FORTRAN: Statement को अलग अलग करने के लिए end of line को use किया जाता है |
Prascal : इसमें colon को use नहीं किया जाता है |
C++ : इसमें semicolon को use किया जाता है |
C++ Comment
C++ को double dash (//) से define किया किया है |comment को किसी प्रोग्राम के statement को प्रोग्रामर को सामने के लिए extra information को define करता है |complier comment को ignore करता है |C++ मे भी एस होता है | उदाहरण के लिए :-
#include<iostream>
void main()
{
using namespace std;
cout<< My first program ;
cout<< Parth;
getch();
}
C++ comment ‘//’ से start होता है और line के end तक चलता है |उदहारण के लिए
#include<iostream>
void main()
{
using namespace std;
cout<< My first program ; // display message
cout<< Parth;
getch();
}
इस कोर्स मे , comment को bold मे लिखा जाता है |
Preprocessor
जब किसी c++ प्रोग्राम मे input और output statement को use किया जाता है तो
#include<iostream.h>
using namespace std;
statements को use किया जाता है |अगर compiler को इन दोनों lines को compile नहीं करता है तब इस single statement को भी use कर सकते है |
#include<iostream.h>
C++ Pre processor को use किया जाता है |जो की प्रोग्राम मे use की जाने वाली source file को define करता है|C++ translator c++ प्रोग्राम को c प्रोग्राम मे convert करता है |यह पर #include एक directive है जको की <> मे लिखे source file को लिंक करते है |directive से source file मे लिखे content प्रोग्राम मे add किया जाता है |
iostream.h मे i का मतलब input है और o का मतलब output होता है |इस file बहुत सारे function include होते है |जैसे
cout : console screen पर data को print करने के लिए |
cin : यूजर द्वारा input की जाने वाले input को read करने के लिए use किया जाता है |
iostream.h को modify नहीं कर सकते है |इसे main() function मे केवल use कर सकते है |
Header file name :
#include <iostream.h> मे iostream , source file का नाम है | iostream.h को header file कहते है |C++ मे कई सारे header files होती है |जो की बहुत सारे functions की definition को hold करता है|C language मे header file को ‘h’ से define करते है |उदाहरण के लिए :
math function के लिए math.h को इस्तेमाल करता है |
लेकिन c++ मे ‘h’ extension को use नहीं भी कर सकते है |c header file को c++ मे भी use कर सकते है |लेकिन इस file को rename किया जाता है जैसे
math.h को c++ मे cmath को use किया जाता है जो की math के बहुत सारे functions को use किया जाता है |
| header file name | old style | new style | Comments |
| iostream | iostream .h | iostream | Input /output |
| Math | Math.h | Cmath | Math operation |
| String | string.h | cstring | String operation |
| Conio | Conio.h | cconio | Conio function |
Namespace
अगर iostream .h की जगह iostream को use किया जाता है तब name space को use किया जाता है |इसका syntax है :
using namespace std ;
इसे directive कहते है |इस statement का use memory management के लिए किया जाता है|
name space c++ का नया feature है जो की c++ मे combine करना complusy होता है |
COUT
इस function का use console screen पर आउटपुट statement को print करने के लिए किया जाता है |इसका उदाहरण है :-
cout << “good morning” ;
statement का जो पार्ट double quotes “” मे close होता है उसे message कहते है |इस statement मे good morning एक character string है जो की console screen पर print होता है | << नोटेशन का use string को console function मे सेंड किया जाता है |इसमें string के फ्लो की डायरेक्शन को define करता है |
C++ : Program Format मे प्रोग्राम format के तीन मतवपूर्ण भागो को discuss किया है अब आगे वाले article मे बाकि के तीन भागो को discuss करते है |
Recent Posts
Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic
Question Tag Definition • A question tag is a small question at the end of a…
2 weeks ago
Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)
Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…
2 weeks ago
Report Writing examples in english grammer How to Write Reports explain Exercise
Report Writing • How to Write Reports • Just as no definite rules can be laid down…
2 weeks ago
Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th
Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…
2 weeks ago
विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features
continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…
2 weeks ago
भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC
भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…
2 weeks ago