SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
C program to describe about structure in c
C program to describe about structure in c
#include
#include
#include
struct student { int rno; char name[50]; int mark; struct student *next; }; struct student* newstudent(int r,char *str,int m) { struct student *new=(struct student*)malloc(sizeof(struct student)); new->rno=r; strcpy(new->name,str); new->mark=m; return new; } struct student* insert(struct student *s,int r,char *str,int m) { struct student *temp=newstudent(r,str,m); temp->next=s; s=temp; return s; } void printstudents(struct student *s) { while(s!=NULL) { printf("%d %s %d\n",s->rno,s->name,s->mark); s=s->next; } } int main(void) { struct student *s=NULL; int r,m; int i; char str[50]; for(i=0;i<2;i++) { scanf("%d %s %d",&r,str,&m); s=insert(s,r,str,m); } printstudents(s); return 0; }
PREVIOUS
NEXT
HOME