Showing posts with label Array of Structures. Show all posts
Showing posts with label Array of Structures. Show all posts

Saturday, October 24, 2026

Structures in C Language Array of Structures in Telugu Part-11 | LearnTechSoft

Structures in C Language | Full Guide in Telugu

Part-11: Different types data ni okasari ela store cheyali? - LearnTechSoft

💡 Real Life: Array lo oke type - 5 marks (int). Mari Student details: Name (String), Roll (int), Marks (float), Age (int) - Different types! Okasari store cheyali ante Structure vadali!

1. Array vs Structure - Difference

ArrayStructure
Same type matrame (int/int)Different types (int+float+char)
marks[5]Student - name, roll, marks
Real-life ki saripoduReal-life data ki perfect

2. Structure Declaration

// Structure Create
struct Student {
    char name[50];
    int roll;
    float marks;
    int age;
};

// Use cheyadam
struct Student s1; // s1 ane variable

// Values pettadam
strcpy(s1.name, "Ramesh");
s1.roll = 101;
s1.marks = 85.5;
s1.age = 20;

// Print
printf("Name: %s\n", s1.name);
printf("Roll: %d\n", s1.roll);

3. Full Program - Student Details

#include <stdio.h>
#include <string.h>

struct Student {
    char name[50];
    int roll;
    float marks;
};

int main() {
    struct Student s1;
    
    printf("Enter Name: ");
    fgets(s1.name, 50, stdin);
    
    printf("Enter Roll: ");
    scanf("%d", &s1.roll);
    
    printf("Enter Marks: ");
    scanf("%f", &s1.marks);
    
    printf("\n--- Student Details ---\n");
    printf("Name: %s", s1.name);
    printf("Roll: %d\n", s1.roll);
    printf("Marks: %.2f\n", s1.marks);
    
    return 0;
}

4. Array of Structures - Super Concept!

60 Students data kavali ante 60 structures! Array of Structures vadatam.

struct Student class[60]; // 60 students!

// First student
class[0].roll = 101;
strcpy(class[0].name, "Ramesh");

// Second student
class[1].roll = 102;
strcpy(class[1].name, "Suresh");

// Loop tho 60 mandi input teesukovachu
for(int i=0; i<60; i++) {
    scanf("%d", &class[i].roll);
}

5. Structure vs Union - Small Difference

Interview:
Structure: Anni members ki separate memory - 50+4+4 = 58 bytes
Union: Okkate memory ni share chesukuntayi - Biggest member size matrame - 50 bytes
Structure ekkuva vadatam - Union thakkuva.

🎯 Next Post: File Handling in C - Part-12 - Last Core Topic!

Practice: Employee (name, id, salary) structure tho 5 employees data store cheyandi!

Abstraction in Java - Explained in Simple Words with Examples in Telugu | LearnTechSoft Abstraction in Java - Explained in Simpl...