C Program to print student details using a structure


In this program, You will learn how to print student details using structure in c.


struct struct_name { 
  //statement
};

Example: How to print student details using structure in c.

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

struct Student {
    char roll[10];
    char name[100];
    char university[100];
};

int main() {

    char newline;
    struct Student st;

    printf("Enter your Roll:");
    scanf("%[^\n]%*c", st.roll); 


    printf("Enter Your Name : ");
    scanf("%[^\n]%*c", st.name); 

    printf("Enter University Name : ");
    scanf("%[^\n]%*c", st.university); 

    printf( "\n\nYour Roll is:%s", st.roll);
    printf( "\nYour Name is:%s", st.name);
    printf( "\nYour University is:%s", st.university);

    return 0;
}

Output:

Enter your Roll:101
Enter Your Name : Xiith.com
Enter University Name : Xiith34


Your Roll is:101
Your Name is:Xiith.com
Your University is:Xiith34