Structure In Hindi

Structure In C++ In Hindi – CPP Data Structure In Hindi

C++

Structure In C++ In HindiCPP Data Structure In Hindi – Is Article Mai Learn Karne Wale Hai Data Structure Kiya Hota Hai And C plus plus Ka Kiya Istemal Hai ?|

Also Read – C++ Pointers

Data Structure In C++ In Hindi

C++ Structure Mei Aap Dusre Predefined Data Types Ko Create Kar Sakte Hai or Ek Record Teyar Kar Sakte Hai. Jaise ki Aap Kisi Person Ke Bare Me Ek Uska name, address,age store Karvana Chahate Hai to us Person Ke Name Se Ek structure create Kar Sakte Hai or usme Ye 3 variables Create Kar Sakte Hai |

Aesa Karne se Sari Information ek hi Jagah Par Store Hogi or Ek hi Name Ke duvara Access ki ja Sakti Hai |

C++ Structure in Hindi ko Samanjh Yani Understand Karne ke Liye Ham Examples Ko Dekhte Hai.

C++ Defining a Structure in Hindi

Structure ko define karne ke liye struct keyword ka istemal kiya jata hai | is keyword ke bad structure ka unique name diya jata hai |iske bad curly braces mei variables create kiye jate hai or ending curly bracket ke bad semicolon lagaya jata hai |

Syntax:

struct struct_Name
{
     Structure member 1;
     structure member 2;
     …
     Structure member N; 
};
  • Struct ek keyword hai |
  • Struct ka data type koi sa bhi ho sakta hai |
  • Struct_Name matlab aap struct ka koi bhi name rakh sakte hai |
  • Structure member matlab aap usme kiya data rakhna chahte hai |

C++ Creating Structure Variables in Hindi

C Language Or C++ Language Me Ham 2 Types Se Structure Variables Ko Create Kar Sakte Hai. Inhe Ham Ek Ek Karke Dekhte Hai |

  • With structure definition 
  • Without structure definition 

C++ With structure definition 

Jab aap structure definition ke sath hi us type ke variables create karte hai to ending semicolon se pahle aap variables ko comma se separate karke likh dete hai |

Example :

struct Student
{
   int rollno;
}t1,t2;

C++ Without structure definition 

Jab aap structure definition ke sath hi us type ke variables create karte hai to ending semicolon Ke Bad aap struct Keyword + struct_name Or variables ke Sath Aap Struct Variable Create Kar Sakte Hai |

Also Read – Arrays – Lists of Data & Multidimensional Arrays

Example:

struct Student
{
   int rollno;
};
struct Student t1,t2;

C++ Accessing Structure Members in Hindi

Structure members ko Aap 2 tarah se access kar sakte hai | ya to aap members ko values assign karvane ke liye ya fir unki values ko output ke rup me print karwane ke liye ab aap structure members ko access karte hai|

Jab bhi aap kisi bhi structure member ko access karte hai to aesa aap (.) dot operator duvara karte hai |

Example:

#include <iostream>
#include <cstring>
 
using namespace std;
 
struct Books {
   char  title[50];
   char  author[50];
   char  subject[100];
   int   book_id;
};
 
int main() {
   struct Books Book1;        // Declare Book1 of type Book
 
   // book 1 specification
   strcpy( Book1.title, "Learn C++ Programming");
   strcpy( Book1.author, "Danish Ali"); 
   strcpy( Book1.subject, "C++ Programming");
   Book1.book_id = 567840;
  
   // Print Book1 info
   cout << "Book 1 title : " << Book1.title <<endl;
   cout << "Book 1 author : " << Book1.author <<endl;
   cout << "Book 1 subject : " << Book1.subject <<endl;
   cout << "Book 1 id : " << Book1.book_id <<endl;

   return 0;
}

Output:

Book 1 title : Learn C++ Programming
Book 1 author : Danish Ali
Book 1 subject : C++ Programming
Book 1 id : 567840

C++ Array of Structure in Hindi

C++ Structure ko agar ek bar define kar diya jaye or hame 10 student ka data add karna hoto ko aap array ki help se kar sakte hai |

Example :

// array of structures
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

struct movies_t {
  string title;
  int year;
} films [3];

void printmovie (movies_t movie);

int main ()
{
  string mystr;
  int n;

  for (n=0; n<3; n++)
  {
    cout << "Enter title: ";
    getline (cin,films[n].title);
    cout << "Enter year: ";
    getline (cin,mystr);
    stringstream(mystr) >> films[n].year;
  }

  cout << "\nYou have entered these movies:\n";
  for (n=0; n<3; n++)
    printmovie (films[n]);
  return 0;
}

void printmovie (movies_t movie)
{
  cout << movie.title;
  cout << " (" << movie.year << ")\n";
}

Output:

Enter title: Blade Runner
Enter year: 1982
Enter title: The Matrix
Enter year: 1999
Enter title: Taxi Driver
Enter year: 1976
 
You have entered these movies:
Blade Runner (1982)
The Matrix (1999)
Taxi Driver (1976)

Friends Mujhe Umeed Hai Ki Aapko CPP Data Structure In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |

Leave a Reply

Your email address will not be published. Required fields are marked *