ProfessorD.org About C Programming Tutorials C ++ Tutorials Data Structure UNIX/Linux Internship/Major Minor Project

C Programming Practical Lab Assignment Exercises

List of practical programmes in C Language for M. Tech / M.C.A., / B.E./ B.Tech./ Computer Science / B.Sc. / BCA PRACTICAL PROGRAMMING & PROBLEM SOLVING THROUGH C - I / II

Write a C program to create a record using structure having two/five fields.


#include 
struct student_record
{
    char name[50];
    int roll_no;

};

int main()
{
    struct student_record student[5];
    int i;
    printf("Storing Student Information:\n");

    // total five student's record will be entered, student[5]
    for (i = 0; i < 5; ++i)
    {
        //printf("Enter the records of %d student \n",i);
        printf("\n Enter the name of %d student: ", i+1);
        scanf("%s", student[i].name);
        printf("\n Enter the roll number of %d student: ", i+1);
        scanf("%d", &student[i].roll_no);

    }
    printf("\n\n Displaying Student Information:\n\n");

    // displaying information
    for (i = 0; i < 5; ++i) {
        printf("\n Roll number of %d student: %d ", i+1, student[i].roll_no);
        printf("\n Name of of %d student: ", i+1);
        puts(student[i].name);
        printf("\n");
    }
    return 0;
    }

Follow us for Video tutorials on Youtube