Skip to main content

Featured

C Pattern Programs: Square Number and Alphabet Patterns Explained

πŸ”· Square Star Pattern πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { printf("* ");//keep"* " } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Column-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = num; i >= 1; i--) { for(int j = num; j >= 1; j--) { printf("%c ", j + 64);//%c for Character and 64 will be ASIIC VALUE } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Row-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; ...

Student Records Using Structure Array in C

Student Records Using Structure Array in C

✅ Student Records Using Structure Array in C

#include <stdio.h>

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

int main() {
    int n;
    printf("Enter number of students: ");
    scanf("%d", &n);

    struct student s[n];  // Array of structs

    // Input Section
    for(int i = 0; i < n; i++) {
        printf("\n=== ENTER DETAILS OF STUDENT %d ===\n", i + 1);
        printf("Name: ");
        scanf(" %[^\n]", s[i].name);  // Accepts spaces

        printf("Roll Number: ");
        scanf("%d", &s[i].roll);

        printf("Marks: ");
        scanf("%f", &s[i].marks);
    }

    // Output Section
    printf("\n=== STUDENT DETAILS ===\n");
    for(int i = 0; i < n; i++) {
        printf("\nStudent %d\n", i + 1);
        printf("Name       : %s\n", s[i].name);
        printf("Roll Number: %d\n", s[i].roll);
        printf("Marks      : %.2f\n", s[i].marks);
    }

    return 0;
}
  

πŸ“˜ Explanation:

This C program uses an array of structures to store details of multiple students. The structure student has fields for name, roll number, and marks. The program prompts the user for the number of students, then collects their data using a loop, and finally prints all the stored data. Useful in managing records in a structured format.

🧾 Sample Output:

Enter number of students: 2

=== ENTER DETAILS OF STUDENT 1 ===
Name: Naveen Kumar
Roll Number: 101
Marks: 85.5

=== ENTER DETAILS OF STUDENT 2 ===
Name: Ravi Teja
Roll Number: 102
Marks: 91

=== STUDENT DETAILS ===

Student 1
Name       : Naveen Kumar
Roll Number: 101
Marks      : 85.50

Student 2
Name       : Ravi Teja
Roll Number: 102
Marks      : 91.00
  

πŸ”‘ Keywords:

Structure Array in C, C Student Record Program, Array of Structures, Student Information Storage in C, struct keyword in C, C Programming for Beginners

πŸ“Œ Hashtags:

#CProgramming #StructuresInC #StudentRecord #ArrayOfStructures #BeginnerCProgram #CollegeAssignment #LearnCProgramming

Comments

Popular Posts

πŸŒ™