Header Ads Widget

C PROGRAM: Create a structure named student that has Roll number, Name, Course, Semester and E-mail Address as members. Assume appropriate types and size of member. Write a program using structure to read and display the data entered by the user in C Language - Sparsh Blog

 Ans:->


Create a structure named student that has Roll number, Name, Course, Semester and E-mail Address as members. Assume appropriate types and size of member. Write a program using structure to read and display the data entered by the user in C Language.


Program is as follows:--


#include <stdio.h>

struct StudentData

{

        int rollno;

        char name[50];

        char course[50];

        int sem;

        char email[50];

};

void main()

{

        struct StudentData s;

        printf("Enter student roll number:");

        scanf("%d", &s.rollno);

        printf("\n Enter student name:");

        scanf("%s", s.name);

        printf("\n Enter course name:");

        scanf("%s", s.course);

        printf("\nEnter student semester");    

        scanf("%d", &s.sem);

        printf("\nEnter student mail address:");

        scanf("%s", s.email);

        printf("\nStudent Rollno is: %d", s.rollno);

        printf("\nStudent Name is: %s", s.name);

        printf("\nStudent Course Name is: %s", s.course);

        printf("\nStudent semester is: %d", s.sem);

        printf("\nStudent Mail address is: %s", s.email);

}


OUTPUT:---


Enter student mail address : sam@gmail.com


Student Rollno is : 12

Student Name is : sam

Student course Name is : mechanical

Student semester is : 3 

Student Mail address is : sam@gmail.com



THANKU FOR READING THIS ARTICLE ON-


If you want to suggest any changes in the program please feel free to contact us in the comment section or you can reach us using Contact us Page.







Post a Comment

0 Comments