You are on page 1of 3

ASSIGNMENT 8

#include<stdlib.h>
#include<stdio.h>\
struct details
{
char name[40];
int roll_number;
enum{y1,y2,y3,y4}i;
enum program{Btech,Mtech,PhD}j;
enum descipline{CSE,EE,ME,CIVIL}k;
};
struct details *func()
{
struct details *ptr;
ptr=(struct details*)malloc(sizeof(struct details));

printf("Please entre the name of the student : ");


scanf("%s",ptr->name);
printf("\nPlease entre the roll number : ");
scanf("%d",&ptr->roll_number);
printf("\nPlease entre the year : ");
scanf("%d",&ptr->i);
printf("\nPlease entre the code for your Degreeprogram(Btec-0,Mtec-1,PhD-2)
: ");
scanf("%d",&ptr->j);
printf("\nPlease entre the code for your Curriculum(CSE-0,EE-1,ME-2,CIVIL-3
: ");
scanf("%d",&ptr->k);
return ptr;
}
int main()
{
struct details *s;
s=func();
printf("\n\n\nName :");
printf("%s\n",s->name);
printf("roll number :");
printf("%d\n",s->roll_number);
printf("Year :");
switch(s->i)
{
case 1:
printf("first year\n");
break;
case 2:
printf("second year \n");
break;
case 3:
printf("third year \n");
break;
case 4:
printf("fourth year\n");
break;
}
printf("program :");
switch(s->j)
{
case 0:
printf("Btech\n");
break;
case 1:
printf("Mtech\n");
break;
case 2:
printf("PhD \n");
break;
}
printf("Curriculum :");
switch(s->k)
{
case 0:
printf("CSE\n\n\n");
break;
case 1:
printf("EE\n\n\n");
break;
case 2:
printf("ME\n\n\n");
break;
case 3:
printf("CIVIL\n\n\n");
break;
}
return 0;
}

Please enter the name of the student : raja


Please enter the roll number : 34
Please enter the year : 1
Please enter the code for your Degreeprogram(Btec-0,Mtec-1,PhD-2) : 0
Please enter the code for your Curriculum(CSE-0,EE-1,ME-2,CIVIL-3 : 0

Name :raja
roll number :34
Year :first year
program :Btech
Curriculum :cs

You might also like