JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: c++ language in hindi

C++ : Structure in hindi , write what is structure in c++ language with programs and examples explanation

write what is structure in c++ language with programs and examples explanation , C++ : Structure in hindi  :-
इससे पहले के article मे compound data type मे से string को discuss किया गया है | लेकिन अब इस article मे structure data type को discuss करेगे |
Structure
अगर किसी person के address को store करते है | इसमें house number , street name , city और pin-code को store करना होता है | इसमें मे से
house number : जो की integer type है |
street name और city : दोनों ही string है |
pincode : ये integer data type है |
इसके लिए array और string दोनों ही data type उपयुक्त नहीं है | array कई सारे data को store कर सकता है लेकिन सभी data सामान होता है |अतः इसका उदाहरण होता है :
int a[20];
इसमें 20 integer value को store हो सकता है |लेकिन मिक्स datatype store नहीं हो सकता है |
इसके लिए structure data type को use किया जाता है | structure एक एस data type है जिसमे अलग अलग data types के values store होती है |structure  data type से address के सभी elements को store किया जा सकता है | जब हमे एक या एक से ज्यादा person की address को store करना होता है तब structure  के array को use किया जा सकता है |
structure datatype OOPs का सबसे महतवपूर्ण concept होता है जो की OOPs के concept के implement मे use होता है |
Structure एक यूजर define data type है | Structure data type है जिसके type से दुसरे variable को declare किया गया है | Structure को declare करने के बाद इसके type का variable को declare किया जा सकता है |
किसी Structure को declare करने के लिए दो भाग होते है :
1.Structure name
इसमें Structure के नाम को define किया जाता है | इसके लिए struct keyword को use किया जाता है | इसका syntax होता है :
struct Structure_name {
Structure Description ;
};
2.Structure Description
Structure Description मे Structure के  members को define किया जाता है | इसमें Structure मे store होने वाली अलग अलग data type के variable को define किया जाता है | इसका syntax है :-
struct address {
int house ;
char street[20];
char city[20];
int pincode;
};
इस उदाहरण मे , address एक Structure data type है जिसमे चार variables define किया गया है :
int house : इसमें address मे से house number को store किया जाता है |
char street[20]; इसमें address मे से street का नाम store होता है |
char city[20];इसमें address मे से city का नाम store होता है|
int pincode;इसमें address मे से pin code store होता है|
Input और Output in Structure
किसी Structure के member को access करने के लिए memebership operator (.) का use किया जाता है | उदाहरण के लिए
अगर Structure address मे से city को access करना है तो इसका syntax address.city होगा |
अगर Structure address मे से house  को access करना है तो इसका syntax address.house होगा |
अगर Structure address मे से pincode  को access करना है तो इसका syntax address.pincode होगा |
जब address.house का type integer होता है क्योकि house का type integer होता है | अतः address.city का type string होता है क्योकि city का data type string होता है |


Structure का उदाहरण :
#include<iostream.h>
#include<conio.h>
struct address {
int house ;
char street[20];
char city[20];
int pincode;
};
void main()
{
struct address s;
using namespace std;
cout<< “Enter House Number : “<<endl;
cin>>s.house;
cout<<“Enter Street Name :”<<endl;
cin.get(s.street);
cout<<“Enter City Name :”<<endl;
cin.get(s.city);
cout<<“Enter Pin Code :”<<endl;
cin>>s.pincode;
cout<<“House Number : “<<s.house<<endl;
cout<<“Street Name : “<< s.street<<endl;
cout<<“City Name : “<< s.city <<endl;
cout<<“Pin Code : “<< s.pincode <<endl;
cout<<“Process Completed ! Forward To Next Form.”<<endl;
getch();
}
इस उदाहरण मे , address एक structure है जिसमे किसी address  का निन्म data को add किया जा सकता है |जिसमे से city और street  string है लेकिन इसे declare करने के लिए character को use किया है |
House: इसमें address मे से house number store होगा |
street : इसमें  street का नाम  store होगी |
city : इसमें city की information को store किया जाता है |
इन सभी access करने के लिए membership operator का use किया गया |
इसका आउटपुट होगा :
Enter House Number : 12
Enter Street Name : Ashok Nagar
Enter City : Jaipur
Enter Pincode : 302004
House Number : 12
Street Name : Ashok Nagar
City : Jaipur
Pincode : 302004


Structure with string class
String class को Structure के साथ use किया जा सकता है |  लेकिन कभी कभी ये compiler पर भी निर्भर करता है | जैसे Borland c++ 5.5 और Microsoft visual C++ version 7.0 , String class को Structure के साथ use नहीं कर सकता है |
जब किसी string को Structure के साथ use किया जाता है तब std namespace को जरुर use किया जा सकता है | इससे using namespace std ; से बना सकते है | या std:: string; statement से use किया जा सकता है |
उदाहरण के लिए :
#include<iostream.h>
#include<conio.h>
#include<string>
struct student {
int RollNumber;
std::string name;
std::string class;
int grade;
};
void main()
{
struct student s;
using namespace std;
cout<< “Enter Roll Number : “<<endl;
cin>>s.RollNumber;
cout<<“Enter Student Name :”<<endl;
cin.get(s.name);
cout<<“Enter Class :”<<endl;
cin.get(s.class);
cout<<“Enter Grade :”<<endl;
cin>>s.grade;
cout<<“Roll Number  : “<<s.RollNumber<<endl;
cout<<“Name : “<< s.name <<endl;
cout<<“Class : “<< s.class <<endl;
cout<<“Grade : “<< s.grade <<endl;
cout<<“Process Completed ! Forward To Next Form.”<<endl;
getch();
}
इस उदाहरण मे , student एक structure है जिसमे किसी student  का निन्म data को add किया जा सकता है |जिसमे से class और name string है |
Roll number: इसमें student का roll number store होगा |
Class : इसमें student की class की information store होगी |
grade : इसमें student के द्वार प्राप्त की गयी grade को store किया जाता है |इन सभी access करने के लिए membership operator का use किया गया |

इसका आउटपुट होगा :
Enter Roll Number : 12
Enter Student Name : Rahul
Enter Class : Fourth
Enter Grade : 81
Roll Number : 12
Name : Rahul
Class : Fourth
Grade : 81

इस article मे ,structure का basic को discuss किया है |अब आगे आने वाले article मे structure के advance feature को discuss करेगे |
Sbistudy

Recent Posts

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

2 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

4 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

7 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

7 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

7 days 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