#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <string.h>
#include <math.h>
#include <time.h>

typedef struct 
{
	int x,y,z;
} Point3D;

typedef struct st
{
	float CGPA;
	int age;
	char name[100];
	struct st *next;
} Student;

typedef struct
{ 
	int a;
	char b;
} Foo;

void printStudentInfo(Student *a)
{
	printf("Name : %s\n",(*a).name);
	printf("Age : %d\n",a->age);
	printf("CGPA : %.2f\n",a->CGPA);
}

void insertNewStudent(Student *list)
{
	Student *t;
	
	t = (Student *)malloc(sizeof(Student));
	
	t -> age = rand()%25+18;
	t -> CGPA = (rand()%400)/100.0;
	strcpy(t->name,"random name");
	t->next = NULL;
	
	while (list->next!=NULL)
		list = list->next;
	
	list->next = t;
	
}
void printList(Student *list)
{
    printf("Printing the whole list.....\n");
	while (list!=NULL)
	{
		printf("CGPA = %.2f\n",list->CGPA);
		list = list->next;
	}
}
int main()
{   
	Point3D p1,p2;
	
	Student *head;
	
	Student me;
	
	srand(time(NULL));
	
	p1.x = 4;
	printf("size of Point3D = %d\n",sizeof(Point3D));
	printf("size of Student = %d\n",sizeof(Student));
	
	me.age = 23;
	strcpy(me.name,"John Doe");
	me.CGPA = 3.04;
	
	me.next = NULL;

	printStudentInfo(&me);
	
	head = &me;

	insertNewStudent(head);
	insertNewStudent(head);
	insertNewStudent(head);
	insertNewStudent(head);
	insertNewStudent(head);
	insertNewStudent(head);
	
	printList(head);
	
}


