Sunday, November 28, 2010

Define the structure called student having properties like stud_id, stud_name, stud_branch,and email_add. Write a program which takes the details of

#include

#include

#define SIZE 3

#include

struct student

{

char *stud_id;

char *stud_name;

char *stud_branch;

char *email_add;

}*s;



main()

{

int i = 0;



s = (struct student *)malloc(80);

for(i = 0; i < SIZE; i++)

{

(s+i)->stud_id = (char *)malloc(30);

(s+i)->stud_name = (char *)malloc(30);

(s+i)->stud_branch = (char *)malloc(30);

(s+i)->email_add = (char *)malloc(30);



printf(" +--------------------------------------------------------------+\n |\t\t\tPlease Enter Student %d Details\t\t|\n +--------------------------------------------------------------+\n",i+1);

printf("\nEnter Student ID :");

scanf("%s",(s+i)->stud_id);



printf("\nEnter Student Name :");

scanf("%s",(s+i)->stud_name);



printf("\nEnter Student Branch :");

scanf("%s",(s+i)->stud_branch);



printf("\nEnter Student Address :");

scanf("%s",(s+i)->email_add);

}

for(i = 0; i < SIZE; i++)

{

printf(" \n+------------------------------------------------------------+\n|\t\t\tStudent %d Details\t\t |\n +------------------------------------------------------------+\n",i+1);

printf("\t\nStudent ID :%s",(s+i)->stud_id);

printf("\t\nStudent Name :%s",(s+i)->stud_name);

printf("\t\nStudent Branch :%s",(s+i)->stud_branch);

printf("\t\nStudent Address :%s",(s+i)->email_add);

}



}