C Programming
Computer Programming

C Program using structure to create student record and display them



Write a C program to create student structure having field roll_no, stud_name, class. Pass this entire structure to function and display the structure elements

\* C Program using structure to create student record and display them *\

# include < stdio.h >
# include < conio.h >
struct   stud
{

int roll_no ;
char stud_name[20] ;
int std ;

} ;

void   student( struct stud s )
{

printf(" Student details:\n") ;
printf("--------------------------\n" ) ;
printf(" Roll Number : %d",s.roll_no ) ;
printf("\n Name : %s",s.stud_name ) ;
printf("\n Std : %d",s.std ) ;

}

int   main( )
{

printf(" Enter Student Details\n" ) ;
printf("--------------------------\n") ;
printf(" Roll Number : ") ;
scanf("%d",&s.roll_no) ;
printf(" Name : ") ;
scanf("%s",s.stud_name) ;
printf(" Std. : ") ;
scanf("%d", &s.std ) ;
printf("--------------------------\n") ;
student(s) ;
return 0 ;

}

Output of Program :

Output of C Program using structure to create student record and display them