हिंदी माध्यम नोट्स
C++ : Sizeof और Increment Operator and Decrement operators in hindi in c++ language
जब किसी loop को discuss किया है update statement , increament operator को use किया जाता है | अतः increament operator को किसी control variable को आटोमेटिक increament किया जाता है | इसका syntax होता है :-
variable ++ ;
यहा पर
variable : ये variable का नाम होता है जिसकी value को increment किया जाता है |
++ : ये increament operator का keyword होता है |
increament operator को दो तरह से use किया जाता है :-
Postfix increament operator
जब किसी variable की value को एक बार use करने के बाद increament किया जाता है | इसका उदाहरन होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5];
cout<<“Enter Array Data :”<<endl;
for(i=0;i<5;i++)
{
cin>>a[i];
}
cout<<“Array Element”<<endl;
for(i=0;i<5;i++)
{
cout<<a[i];
}
getch();
}
इस उदाहरण मे array के element को read और display किया जाता है | इसका आउटपुट होता है :-
Enter Array Data : 12 23 43 23 12
Array Element
12 23 43 23 12
Prefix increament operator
जब किसी variable की value को एक बार use करने के पहले increament किया जाता है | इसका उदाहरन होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5];
cout<<“Enter Array Data :”<<endl;
for(i=0;i<5;i++)
{
cin>>a[i];
}
cout<<“Array Element”<<endl;
for(i=0;i<=5;++i)
{
cout<<a[i];
}
getch();
}
इस उदाहरण मे array के element को read और display किया जाता है | सबसे i की value 1 होगी तब array की first element को display किया जाता है | और बाद मे i की value 2 हो जाती है तब array के दूसरी element display किया जाता है | इसका आउटपुट होता है :-
Enter Array Data : 23 21 45 78 6
Array Element
23 21 45 78 6
Decrement operator
जब किसी loop को discuss किया है update statement , Decrement operator को use किया जाता है | अतः Decrement operator को किसी control variable को आटोमेटिक Decrement किया जाता है | इसका syntax होता है :-
variable –;
यहा पर
variable : ये variable का नाम होता है जिसकी value को increament किया जाता है |
— : ये Decrement operatorका keyword होता है |
Decrement operator को दो तरह से use किया जाता है :-
Postfix Decrement operator
जब किसी variable की value को एक बार use करने के बाद Decrement किया जाता है | इसका उदाहरन होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5];
cout<<“Enter Array Data :”<<endl;
for(i=0;i<5;i++)
{
cin>>a[i];
}
cout<<“Array Element”<<endl;
for(i=5;i>0;i–)
{
cout<<a[i];
}
getch();
}
इस उदाहरण मे array के element को read किया जाता है और reverse order मे array के element को display किया जाता है | इसके लिए i की value 5 होती है जिससे array fifth element को display किया जाता है | उसके बाद i की value को Decrement कर दिया जाता है | और array की fourth element को display किया जाता है | ये तब चलता है जब तक i की value ‘0’ से बड़ी होती है | इसका आउटपुट होता है :-
Enter Array Data : 12 23 43 23 12
Array Element
12 23 43 23 12
Prefix Decrement operator
जब किसी variable की value को एक बार use करने के पहले Decrement किया जाता है | इसका उदाहरन होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5];
cout<<“Enter Array Data :”<<endl;
for(i=0;i<5;i++)
{
cin>>a[i];
}
cout<<“Array Element”<<endl;
for(i=5;i=>0;–i)
{
cout<<a[i];
}
getch();
}
इस उदाहरण मे array के element को read किया जाता है और reverse order मे array के element को display किया जाता है | इसके लिए i की value 4 होती है जिससे array fifth element को display किया जाता है | उसके बाद i की value को Decrement कर दिया जाता है | और array की fourth element को display किया जाता है | ये तब चलता है जब तक i की value ‘0’ से बड़ी या सामान होती है | इसका आउटपुट होता है :-
Enter Array Data : 23 21 45 78 6
Array Element
6 78 45 21 23
size of operator
size of operator का use किसी variable के size को calculate करने के लिए किया जाता है | इसका syntax होता है :
sizeof(variable name );
यहा पर ;
sizeof() : ये sizeof() operator का keyword होता है | जिसका use sizeof() को use करने के लिए किया जाता है |
variable name : इसमें variable का नाम होता है जिसकी size को calculate करना होता है |
उदाहरण के लिए :
sizeof(int); इस statement से integer variable के size को calculate किया जाता है |
sizeof(float); इस statement से float variable के size को calculate किया जाता है |
sizeof(double); इस statement से double variable के size को calculate किया जाता है |
sizeof(char); इस statement से character variable के size को calculate किया जाता है |
इसका उदाहरण होता है :-
#include<iostream.h>
#include<conio.h>
void main()
{
int a;
char c;
double b;
float f;
cout<<“Enter Integer Value :”<<endl;
cin>>a;
cout<<“Enter Character Value :”<<endl;
cin>>c;
cout<<“Enter Flaot Value :”<<endl;
cin>>f;
cout<<“Enter Double Value :”<<endl;
cin>>d;
cout<<“Value of a: “<<a<<“And Size of a :”<<sizeof(a)<<endl;
cout<<“Value of b: “<<b<<“And Size of b :”<<sizeof(b)<<endl;
cout<<“Value of c: “<<c<<“And Size of c :”<<sizeof(c)<<endl;
cout<<“Value of f: “<<d<<“And Size of f :”<<sizeof(f)<<endl;
getch();
}
इसका आउटपुट होगा :
Enter Integer Value : 12
Enter Character Value : w
Enter Float Value : 12.23
Enter Double Value : 12.342456
Value of a: 12 And Size of a : 8
Value of b: 12.342456 And size of b : 32
Value of c: w And Size of c : 2
Value of f: 12.23 And Size of f : 12.23
इस article मे increment और decrement और sizeof() operator को discuss किया है | जिससे प्रोग्रामर को programming skill को बढाया जा सकता है |
Recent Posts
सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है
सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…
मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the
marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…
राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi
sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…
गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi
gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…
Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन
वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…
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 ,…