हिंदी माध्यम नोट्स
C++ : Compound Data Type Examples in hindi , what is Compound Data Type Example in c++ language
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();
}
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 ,…