C++ header file in hindi
C ++ में, एक program बनाने से पहले हम program के header section में कुछ pre-defined library files include करते हैं।
इन files में,बहोत से pre-defined function होते हैं जिनमें किसी task के लिए code होता है। एक program में इन functions का उपयोग करने के लिए, हमें उनकी फ़ाइल (जिसमे ये defined हैं) को program के header में include करते।
एक program में , header files को include करने का syntax नीचे दिया गया है –
#include<filename.h>
इसमें h, file extension है।
cout in C++ in hindi
cout statement का उपयोग monitor screen पर किसी message या result को print करने के लिए किया जाता है क्योंकि यह output operation किया जाता है इसलिए इसे C ++ में output statement के नाम से भी जाना जाता है-
cout<<"message";
इसमें << को insertion operator कहलाता है।
cin in C++ in hindi
cin एक input statement है जो program execution के समय runtime पर किसी variable की value को read करता है जो किसी input device जैसे keyboard input किये जाते हैं।
Example
cin>>variable1;
cin>>variable2;
or
cin>>variable1>>variable2;
इसमें >> को insertion operation कहा जाता है।
एक variable में store value को output statement कहा जाता है।
Example
cout<<variable1<<variable2;
C++ hello world program
यह एक simple program है जिसमे हम एक message print करते हैं।
नीचे दिया गया program Turbo C++(C++98) पर आधारित है –
#include<iostream.h>
#include<conio.h>
void main()
{
cout<<"Hello world";
getch();
}
OUTPUT
Hello world
Explanation:
ostream.h
और conio.h
, दोनों header file हैं।
void एक return type है, जिसमें main()
एक function है जो एक program का execution point होता है। क्योंकि यहाँ void type function है इसलिए function main()
कोई भी value return करता है।
getch()
एक function है जो output को hold करता है।
Things to know
C ++ में, दोनों statement (cout, cin
) को emicolon (;) द्वारा terminate किया जाता है।
दोनों cout
और cin
को iostream-class के अंतर्गत defined किया गया है, इसलिए हम program में इनकी header file (iostream.h
) को include करते हैं।
cout
statement में, message को double quotes में लिखा जाता है, जबकि cin
statement में किसी statement की value read करने के लिए double quotes का use नहीं होता।
program किसी variable की value को display करने के लिए, outout statement में double quotes का use नहीं होता है।
अगर आप visual studio (C++11/12/17)पर हैं तो यह कुछ इस प्रकार का होगा –
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello world";
return 0;
}
OUTPUT
Hello world
इसके लिए आप यहाँ देखें Why “using namespace std” is used after including iostream
It’s so helpful brother 😀👍💐