JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: c++ language in hindi

C++ : Compound Data Type Examples in hindi , what is Compound Data Type Example in c++ language

what is Compound Data Type Example in c++ language , C++ : Compound Data Type Examples in hindi  :-
इस article मे  compound data type के कुछ उदाहरनो को discuss करेगे जिससे array , string और structure के concept को अच्छी तरह से समज सके |
array : array एक एस data type है जिसमे कई सामान type के datas को store कर सकते है |
string : string character का combination है |
structure : structure मे दो या दो से अधिक data types के variables को  group होता है |उदहारण -1
इस उदाहरण मे , निन्म information को display किया जाता है |
What is name ? Parth
What is last name ? Patel
What is grade ? A
What is age ? 12
Information
Name : Parth Patel
Grade : A
Age : 12

Expalnation
इस उदाहरन मे , सभी information को store करने के अलग अलग  डट type के variable को use किया जाता है | इसलिए इसमें एक struture को declare किया जाता है | इस struture मे निन्म member है  |
int age : इसमें age को store किया जाता है |
string name : इसमें first name को store किया जाता है |
string last : इसमें last name को store किया जाता है |
char grade : इसमें grade को store किया जाता है |
उसके बाद यूजर द्वारा information को input किया जाता है | इस information को structure के member मे assign किया जाता है |
इसके बाद cout statement से struture के iniformation को display किया जाता है |

Source code
#include<iostream.h>
#include<conio.h>
#include<string.h>
struct person
{
int age;
string first ;
string last ;
char grade ;
};
void main()
{
person p;
cout<<“What is name ?”;
cin>>p.first;
cout<<“What is last name ?”;
cin>>p.last;
cout<<“What is grade ?”;
cin>>p.grade;
cout<<“What is age ?”;
cin>>p.age;
cout<<“Information”<<endl;
cout<<“Name : “<<p.first p.last<<endl;
cout<<“Grade :”<<p.grade<<endl;
cout<<“Age : “<<p.age <<endl;
getch();
}

उदहारण -2
इस उदाहरण मे ,  matrix को display किया जाता है |

Explanation
c language के तरह c++ language मे भी matrix को display किया जाता है | इसके लिए  array को use किये जाता है |
सबसे पहले two dimensional array को declare करेगे |
उसके बाद array के element को input करा लेते है |
उसके बाद loop मे array मे  यूजर द्वारा input किये गये values को input किया जाता है |
फिर loop चलाया जाता है |
पहले loop मे मेट्रिक के row 1 को display किया जाता है |
और inner loop मे matrix की row 2 को display किया जाता है |
Source code
#include<iostream.h>
#include<conio.h>
void main()
{
int a[2][2];
cout<<“Enter data :”;
for (i=0;i<4;i++)
{
cin>>a[i];
}
for(i-0;i<2;i++)
{
for(j=0;j<2;j++)
{
cout<<a[i][j];
}
cout<<endl;
}
getch();
}

उदहारण -3
इस उदाहरण मे , दो  matrix को add किया जाता है |

Explanation
c language के तरह c++ language मे भी matrix को display किया जाता है | इसके लिए  array को use किये जाता है |
सबसे तीन  two dimensional array को declare करेगे | जिसमे  एक array मे matrix a और दुसरे array मे matrix b और तीसरे  array मे दोनों matrix के addition को assign किया जता है |
उसके बाद array के element को input करा लेते है |
उसके बाद loop मे array मे  यूजर द्वारा input किये गये values को input किया जाता है |
उसके  बाद two level looping किया जाता है |
अगर i=0 और j=0 है तब a[0][0] और b[0][0] को add किया जाता है | इसके आउटपुट को c[0][0] मे assign किया जाता है |
अगर i=0 और j=1 है तब a[0][1] और b[0][1] को add किया जाता है | इसके आउटपुट को c[0][1] मे assign किया जाता है |
अगर i=1 और j=0 है तब a[1][0] और b[1][0] को add किया जाता है | इसके आउटपुट को c[1][0] मे assign किया जाता है |
अगर i=1 और j=1 है तब a[1][1] और b[1][1] को add किया जाता है | इसके आउटपुट को c[1][1] मे assign किया जाता है |
इसके बाद मेट्रिक c को display किया जाता है |
Source code
#include<iostream.h>
#include<conio.h>
void main()
{
int a[2][2] ,b[2][2],c[2][2];
cout<<“Enter data of matrix a :”;
for (i=0;i<4;i++)
{
for(j=0;j<2;j++)
{
cin>>a[i][j];
}
}
cout<<“Enter data of matrix b :”;
for (i=0;i<4;i++)
{
for(j=0;j<2;j++)
{
cin>>b[i][j];
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cout<<c[i][j];
}
cout<<endl;
}
getch();
}

उदहारण -4
इस उदाहरण मे , दो  matrix को subtract किया जाता है |

Expalnation
c languge के तरह c++ language मे भी matrix को display किया जाता है | इसके लिए  array को use किये जाता है |
सबसे तीन  two dimensional array को declare करेगे | जिसमे  एक array मे matrix a और दुसरे array मे matrix b और तीसरे  array मे दोनों matrix के addition को assign किया जता है |
उसके बाद array के element को input करा लेते है |
उसके बाद loop मे array मे  यूजर द्वारा input किये गये values को input किया जाता है |
उसके  बाद two level looping किया जाता है |
अगर i=0 और j=0 है तब a[0][0] और b[0][0] को subtract किया जाता है | इसके आउटपुट को c[0][0] मे assign किया जाता है |
अगर i=0 और j=1 है तब a[0][1] और b[0][1] को subtract किया जाता है | इसके आउटपुट को c[0][1] मे assign किया जाता है |
अगर i=1 और j=0 है तब a[1][0] और b[1][0] को subtract किया जाता है | इसके आउटपुट को c[1][0] मे assign किया जाता है |
अगर i=1 और j=1 है तब a[1][1] और b[1][1] को subtract किया जाता है | इसके आउटपुट को c[1][1] मे assign किया जाता है |
इसके बाद मेट्रिक c को display किया जाता है |
Source code
#include<iostream.h>
#include<conio.h>
void main()
{
int a[2][2] ,b[2][2],c[2][2];
cout<<“Enter data of matrix a :”;
for (i=0;i<4;i++)
{
for(j=0;j<2;j++)
{
cin>>a[i][j];
}
}
cout<<“Enter data of matrix b :”;
for (i=0;i<4;i++)
{
for(j=0;j<2;j++)
{
cin>>b[i][j];
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j] – b[i][j];
}
}
cout<<“Output Matrix”;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cout<<c[i][j];
}
cout<<endl;
}
getch();
}

उदहारण -3
इस उदाहरण मे , दो  matrix को multiply किया जाता है |

Expalnation
c languge के तरह c++ language मे भी matrix को display किया जाता है | इसके लिए  array को use किये जाता है |
सबसे तीन  two dimensional array को declare करेगे | जिसमे  एक array मे matrix a और दुसरे array मे matrix b और तीसरे  array मे दोनों matrix के addition को assign किया जता है |
उसके बाद array के element को input करा लेते है |
उसके बाद loop मे array मे  यूजर द्वारा input किये गये values को input किया जाता है |
उसके  बाद two level looping किया जाता है |
अगर i=0 और j=0 है तब a[0][0] और b[0][0] को multiply किया जाता है | इसके आउटपुट को c[0][0] मे assign किया जाता है |
अगर i=0 और j=1 है तब a[0][1] और b[0][1] को multiply किया जाता है | इसके आउटपुट को c[0][1] मे assign किया जाता है |
अगर i=1 और j=0 है तब a[1][0] और b[1][0] को multiply किया जाता है | इसके आउटपुट को c[1][0] मे assign किया जाता है |
अगर i=1 और j=1 है तब a[1][1] और b[1][1] को multiply किया जाता है | इसके आउटपुट को c[1][1] मे assign किया जाता है |
इसके बाद मेट्रिक c को display किया जाता है |
Source code
#include<iostream.h>
#include<conio.h>
void main()
{
int a[2][2] ,b[2][2],c[2][2];
cout<<“Enter data of matrix a :”;
for (i=0;i<4;i++)
{
for(j=0;j<2;j++)
{
cin>>a[i][j];
}
}
cout<<“Enter data of matrix b :”;
for (i=0;i<4;i++)
{
for(j=0;j<2;j++)
{
cin>>b[i][j];
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=a[i][j] * b[i][j];
}
}
cout<<“Output Matrix”;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cout<<c[i][j];
}
cout<<endl;
}
getch();
}

Sbistudy

Recent Posts

मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi

malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…

4 weeks ago

कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए

राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…

4 weeks ago

हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained

hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…

4 weeks ago

तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second

Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…

4 weeks ago

चौहानों की उत्पत्ति कैसे हुई थी ? chahamana dynasty ki utpatti kahan se hui in hindi

chahamana dynasty ki utpatti kahan se hui in hindi चौहानों की उत्पत्ति कैसे हुई थी…

1 month ago

भारत पर पहला तुर्क आक्रमण किसने किया कब हुआ first turk invaders who attacked india in hindi

first turk invaders who attacked india in hindi भारत पर पहला तुर्क आक्रमण किसने किया…

1 month 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