Feb 17, 2022

Structures in C (2)

structures in C.

 #include<stdio.h>
struct student
{
    char* name;
    int roll_no;
    float perc_prev_yr;
    int admiss_yr;
};

int main(int argc, char const *argv[])
{
    struct student student_1;
    struct student student_2;
    struct student student_3;
    struct student student_4;

    student_2.name = "Madan";
    student_2.roll_no = 2002;
    student_2.perc_prev_yr = 78.31;
    student_2.admiss_yr = 2020;

    student_3.name = "Mohan";
    student_3.roll_no = 1950;
    student_3.perc_prev_yr = 85.0;
    student_3.admiss_yr = 2019;

    student_4.name = "Raman";
    student_4.roll_no = 1730;
    student_4.perc_prev_yr = 80.50;
    student_4.admiss_yr = 2017;

    printf("Name :%s\n", student_3.name);
    printf("Roll_number :%d\n", student_3.roll_no);
    printf("Previous Year Percentage :%.2f\n", student_3.perc_prev_yr);
    printf("Admission Year :%d\n", student_3.admiss_yr);

    return 0;
}

No comments:

Post a Comment

Comparing two files in C language.

Operations on More than one File.    # include < stdio.h > # include < stdlib.h > # include < string.h > int main ( int ...