JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

Structure : Array or Nesting in hindi in c language स्ट्रक्चर : अरे या नेस्टिंग इन c कंप्यूटर भाषा में हिंदी में

स्ट्रक्चर : अरे या नेस्टिंग इन c कंप्यूटर भाषा में हिंदी में Structure : Array or Nesting in hindi in c language :-
इससे पहले structure title article मे , structure  का syntax और operation को स्टडी किया है |अब इस article मे,हम structure का array और function से लिंक को पड़ेगे |
1. Array of structure
structure  का use ,अलग-अलग type के data value जो एक variable से कनेक्ट करते है को use करने के लिए किया जाता है |उदहारण के लिए ,किसी students के मार्क्स को store करने केलिए ,दो data  type ,students name और marks का structure  बनाया|लेकिन जब हमे 100 student  के data को store करना हो तब  हमे  इस structure का array बनाना पड़गे |structure  की array बनाने के लिए syntax है :-
1.structure  का definition ,simple structure  के तरह होता है |
2.structure declaration मे , variable को array syntax मे declare करते है :इसका syntax है :
struct structure_name variable_name[size];
यह size का मतलब है number of variable |
3.Structure member access मे , variable_name[size].member से कर सकते है |
उदहारण के लिए :
#include<stdio.h>
#include<conio.h>
struct marks
{
char name[15];
int english ;
int hindi ;
};
void main()
{
struct marks student[20];
int n,i;
printf(“Enter Number of students “);
scanf(“%d”,&n);
printf(“Enter name of %d Students”,n);
for(i=0:i<n;i++)
{
gets(students[i].name);
}
printf(“Ente marks of %d Students”);
for(i=0:i<n;i++)
{
printf(“%d”,&students[i].english);
gets(“%d”,&students[i].hindi);
}
for(i=0;i<n;i++)
{
printf(“Details of %d students”,i);
printf(“Name=%s”,students[i].name)’
printf(“English marks =%d”,students[i].english);
printf(“Hindi marks =%d”,students[i].hindi);
}
getch();
}
इस उदहारण मे का आउटपुट होगा :-
Enter Number of students 1
Enter name of 1 Students Parth
Ente marks of 1 Students 56 67
Details of 1 students
Name=Parth
English marks =56
Hindi marks =67
हमने देखा structure variable की array लेकिन जब structure member मे array होती है तब उसे  किस प्रकार से use करेगे |इस concept को समजने के लिए नीचे दिए उदाहरण को स्टडी  करना पड़ेगे :-
#include<stdio.h>
#include<conio.h>
struct marks
{
char name[15];
int marks[2];
};
void main()
{
struct marks student[20];
int n,m,i,j;
printf(“Enter Number of students “);
scanf(“%d”,&n);
printf(“Enter Number of subject “);
scanf(“%d”,&m);
printf(“Enter name of %d Students”,n);
for(i=0:i<n;i++)
{
gets(students[i].name);
}
printf(“Ente marks of %d Students”);
for(i=0:i<n;i++)
{
for (j=0:j<m;j++)
{
printf(“%d”,&students[i].marks[j]);
}
}
for(i=0;i<n;i++)
{
printf(“Details of %d students\n”,i);
printf(“Name=%s\n”,students[i].name);
for(j=0;j<m;j++)
{
printf(“Subject[%d]:%d\n”,j,students[i].marks[j]);
}
getch();
}
इस उदहारण मे , marks[2] एक array है जो किसी एक student के दो subjects के marks को store करता है |marks को read और write करने के लिए , two dimensional array के concept को use किया जाता है |
जैसे number of students 2
i=0 होने पर ,students[0].marks[0] पर पहले students के  पहले subject के मार्क्स store होगा :
                  students[0].marks[1] पर पहले students के दुसरे subject का mark store होगा :
i=1 होने पर ,students[1].marks[0] पर दुसरे स्टूडेंट के पहले subject के mark store होगा :
                  students[0].marks[1] पर दुसरे student के दुसरे subject का mark store होगा :
आउटपुट होगा :
Enter Number of students 2
Enter name of 2 Students Parth Om
Enter marks of 2 Students 56 67 78 45
Details of 1 students
Name=Parth
Subject [1]=56
Subject [2] =67
Details of 2 students
Name=Om
Subject [1]=78
Subject [2] =45
2.Nested Structure :
C language मे , Structure की nesting हो सकती है जिसे Structure की complxity तो बदती है लेकिन Structure की flexibility भी बदती है |
इसके उदाहरन के लिए :
struct person{
char name [15];
int birth_day;
char birth_month[10];
int birth_year ;
char sex[5];
int salary;
};
इस उदाहरण मे , int birth_day;,char birth_month[10];, int birth_year ; तीन variable है जो एक group date से belong कर सकते है अतः इन तीनो एक structure मे group कर सकते है |
जैसे :
struct person         // Outer Structure
{
char name [15];
struct DOB          // Inner Structure
{
int birth_day;
char birth_month[10];
int birth_year ;
};
char sex[5];
int salary;
};
इसमें DOB एक structure है जिसमे person की date of birth store होगी |इस structure को किस प्रकार से C प्रोग्राम मे use करेगे :-
Structure declaration तो same रहेगा|
Structure member access का syntax होगा :
outer Structure 1 variable_name . inner Structure variable_name .member;
इसका उदहारण है :-
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct person         // Outer Structure
{
char name [15];
struct DOB          // Inner Structure
{
int birth_day;
char birth_month[10];
int birth_year ;
};
char sex[5];
int salary;
} person1;
void main()
{
printf(“Enter name “);
gets(person1.name);
printf(“Enter day of Birth”);
scanf(“%d”,&person1.DOB.birth_day);
printf(“Enter month of birth”);
gets(person1.DOB.birth_month);
printf(“Enter Year of birth”);
scanf(“%d”,&person1.DOB.birth_year);
printf(“Enter your Sex”);
gets(person1.sex);
printf(“Enter salary”);
scanf(“%d”,&person1.salary);
printf(“Details”)
printf(“name : %s”,person1.name);
printf(“DOB : %d-%s-%d”,person1.DOB.birth_day, person1.DOB.birth_month,person1.DOB.birth_year);
printf(“Sex : %s”,person1.sex);
printf(“Salary : %s”,person1.salary);
getch();
}
आउटपुट होगा :
Enter name Parth
Enter day of birth 17
Enter month of birth December
Enter year of birth 1995
Enter sex Male
Enter Salary 20000
Details
Name : Parth
DOB : 17-December-1995
Sex : Male
Salary : 20000
Inner Structure  मे एक या एक से अधिक variable हो सकते है |
नोट :
C language मे , 15 level तक nesting allow है |
और
C99 (Sharp C) मे , 63 level तक nesting allow है |
level का मतलब है किसी Structure मे Structure  को declare करना |उपर दिए गये उदहारण का level 2 है |
Sbistudy

Recent Posts

Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic

Question Tag Definition • A question tag is a small question at the end of a…

2 weeks ago

Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)

Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…

2 weeks ago

Report Writing examples in english grammer How to Write Reports explain Exercise

Report Writing • How to Write Reports • Just as no definite rules can be laid down…

2 weeks ago

Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th

Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…

2 weeks ago

विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features

continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…

2 weeks ago

भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC

भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…

2 weeks 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