Sure! Here’s a bilingual explanation (Hindi + English) of each concept related to Structures from your image — with examples where needed:
📘 Structures in C (स्ट्रक्चर इन C)
A structure is a user-defined data type used to group related data types together.
Structure एक ऐसा डेटा टाइप है जिसमें आप कई अलग-अलग प्रकार के डेटा को एक साथ रख सकते हैं।
✅ 1. Defining a Structure
English: Create a blueprint using struct
.
Hindi: struct
की मदद से एक structure टाइप बनाते हैं।
struct Student {
int roll;
char name[20];
float marks;
};
✅ 2. Declaring Structure Variables
English: After defining, create variables of the structure.
Hindi: Structure define करने के बाद, उसके टाइप के variables बनाते हैं।
struct Student s1, s2;
✅ 3. Accessing Structure Elements
English: Use the dot .
operator.
Hindi: Dot (.
) ऑपरेटर से structure के members को access करते हैं।
s1.roll = 101;
strcpy(s1.name, "Rahul");
s1.marks = 89.5;
✅ 4. Passing Structure to Functions (By Value & Reference)
🔹 By Value (कॉपी भेजना):
void display(struct Student s) {
printf("%d", s.roll);
}
🔹 By Reference (पता भेजना):
void display(struct Student *s) {
printf("%d", s->roll);
}
Hindi: Value से भेजने पर structure की कॉपी जाती है।
Reference से भेजने पर address भेजते हैं जिससे असली डेटा बदल सकता है।
✅ 5. Function Returning Structure
English: A function can return a structure.
Hindi: कोई function structure को return कर सकता है।
struct Student getStudent() {
struct Student s = {101, "Amit", 92.0};
return s;
}
✅ 6. Array of Structures
English: Store multiple structure variables.
Hindi: Structure के कई objects को array में स्टोर कर सकते हैं।
struct Student class[50];
✅ 7. Passing Array of Structures to Function
English: Send whole array as argument.
Hindi: Structure का पूरा array function को भेज सकते हैं।
void displayAll(struct Student s[], int n);
Would you like this in PDF/notes format for revision or practice questions too?
Computer lab:
#include <iostream>
#include <string>
using namespace std;
// Declare a structure named "car"
struct car {
string brand;
string model;
int year;
};
int main() {
car myCar1, myCar2;
// Input for first car
cout << "Enter details for Car 1:\n";
cout << "Brand: ";
getline(cin, myCar1.brand);
cout << "Model: ";
getline(cin, myCar1.model);
cout << "Year: ";
cin >> myCar1.year;
cin.ignore(); // To clear the newline character from input buffer
// Input for second car
cout << "\nEnter details for Car 2:\n";
cout << "Brand: ";
getline(cin, myCar2.brand);
cout << "Model: ";
getline(cin, myCar2.model);
cout << "Year: ";
cin >> myCar2.year;
// Output
cout << "\nCar 1: " << myCar1.brand << " " << myCar1.model << " " << myCar1.year << "\n";
cout << "Car 2: " << myCar2.brand << " " << myCar2.model << " " << myCar2.year << "\n";
return 0;
}
Output:
Enter details for Car 1:
Brand: Toyota
Model: Corolla Altis
Year: 2015
Enter details for Car 2:
Brand: Honda
Model: Civic
Year: 2018
Car 1: Toyota Corolla Altis 2015
Car 2: Honda Civic 2018
Here are bilingual exam notes (English + Hindi) based on the Object Oriented Programming (OOP) topics from your image.
📘 Object Oriented Programming (OOP) – Exam Notes
ऑब्जेक्ट ओरिएंटेड प्रोग्रामिंग – परीक्षा नोट्स
🔹 1. Concept of Object Oriented Programming
English: OOP is a programming paradigm based on the concept of “objects”.
Hindi: OOP एक प्रोग्रामिंग तरीका है जो “objects” के कॉन्सेप्ट पर आधारित होता है।
🔹 2. Data Hiding
English: Restricting access to internal details of an object.
Hindi: किसी object के अंदर की जानकारी को छुपाना।
Example: Using
private
keyword.
🔹 3. Data Encapsulation
English: Wrapping data and functions together into one unit (class).
Hindi: डेटा और functions को एक साथ एक यूनिट (class) में बाँधना।
Example: A class that contains both variables and methods.
🔹 4. Class and Object
Class
- English: A blueprint or template to create objects.
- Hindi: Objects बनाने के लिए एक खाका (template)।
Object
- English: An instance of a class.
- Hindi: Class का एक असली उदाहरण (object)।
class Car {
public:
string brand;
};
Car myCar; // object
🔹 5. Abstract Class and Concrete Class
Abstract Class
- English: A class with at least one pure virtual function.
- Hindi: जिसमें कम से कम एक pure virtual function हो।
Cannot be instantiated directly.
Concrete Class
- English: A class that can be instantiated and has complete definitions.
- Hindi: पूरी तरह से defined class जिसे object बनाया जा सकता है।
🔹 6. Polymorphism
English: Same function behaves differently in different situations.
Hindi: एक ही नाम का function अलग-अलग तरीकों से काम करता है।
➤ Function Overloading (C++ Example)
Multiple functions with same name but different parameters.
int add(int a, int b);
float add(float x, float y);
🔹 7. Inheritance
English: A class can inherit properties of another class.
Hindi: एक class दूसरी class की properties को प्राप्त कर सकती है।
class Animal {
public:
void speak();
};
class Dog : public Animal {};
🔹 8. Advantages of OOP over Earlier Programming
Feature | OOP | Earlier (Procedural) |
---|---|---|
Reusability | ✅ | ❌ |
Data Hiding | ✅ | ❌ |
Scalability | ✅ | ❌ |
Modularity | ✅ | ❌ |
Hindi Summary:
OOP में code reuse होता है, security मिलती है, और maintenance आसान होता है।
📘 Implementation of OOP Concepts in C++
C++ में ऑब्जेक्ट ओरिएंटेड प्रोग्रामिंग के कांसेप्ट का कार्यान्वयन
✅ 1. Definition of a Class (क्लास की परिभाषा)
English: A class is a blueprint that defines data members and member functions.
Hindi: क्लास एक ढाँचा (blueprint) है जिसमें डेटा और फंक्शन होते हैं।
class Student {
int roll; // data member
public:
void getData(); // member function
};
✅ 2. Members of a Class (क्लास के मेंबर्स)
- Data Members: Variables inside a class. (क्लास के अंदर के वेरिएबल्स)
- Member Functions: Functions defined inside a class. (क्लास के अंदर के फंक्शन)
✅ 3. Visibility Modes – Public & Private
English: Controls access to class members.
Hindi: क्लास मेंबर्स को कौन access कर सकता है, यह तय करता है।
private
: accessible only inside the classpublic
: accessible from outside the class
class A {
private:
int x;
public:
void setX(int val) { x = val; }
};
Note: By default, members in a class are private.
✅ 4. Member Function Definition
➤ Inside Class Definition
class A {
public:
void show() {
cout << "Hello";
}
};
➤ Outside Class Definition (Using Scope Resolution ::
)
class A {
public:
void show();
};
void A::show() {
cout << "Hello";
}
✅ 5. Declaration of Objects (ऑब्जेक्ट बनाना)
English: Object is an instance of a class.
Hindi: Object, class का असली उपयोग (instance) होता है।
Student s1, s2;
✅ 6. Accessing Members from Objects (ऑब्जेक्ट से डेटा एक्सेस करना)
s1.setData(); // calling public member function
✅ 7. Array of Objects (ऑब्जेक्ट्स का ऐरे)
English: Store multiple objects using an array.
Hindi: कई objects को एक array में स्टोर किया जाता है।
Student arr[10];
✅ 8. Objects as Function Arguments (फंक्शन में ऑब्जेक्ट भेजना)
➤ Pass by Value (कॉपी भेजना):
void display(Student s);
➤ Pass by Reference (असली डेटा भेजना):
void display(Student &s);