#include<stdio.h>
#include<conio.h>
#define MAX_STD 5
/***************************************************************/
/* This program show the use of typedef and structure */
/* It also show how to assign values in structure and */
/* Shows how to use Structure with Array. */
/***************************************************************/
typedef struct{ //Use typedef in the structure//
char name[12];
int roll_no;
char branch[14];
char subject[15];
int marks;
}STUDENT_TYPE; /*Now STUDENT_TYPE is a data type which is defined by the programmer*/
void main()
{ //and here this data type is used//
STUDENT_TYPE STUDENT[5]; //Array of size as you need//
int i;
for(i=0;i<MAX_STD;i++)
{
printf("\nEnter the database of %d student.",i);
printf("\nEnter the name,roll_no,branch,subject and marks of the student:\n");
scanf("%s",&STUDENT[i].name); /*enter the values bye user to the variabes*/
scanf("%d",&STUDENT[i].roll_no);
scanf("%s",&STUDENT[i].branch);
scanf("%s",&STUDENT[i].subject);
scanf("%d",&STUDENT[i].marks);
}
printf("Inputed Database is:\n\n");
printf("Name\t\tRoll_no\t\tBranch\t\tSubject\t\tMarks\n");
printf("***********************************************************************\n");
for(i=0;i<MAX_STD;i++)
{
printf("%s\t\t",STUDENT[i].name);
printf("%d\t\t",STUDENT[i].roll_no);
printf("%s\t\t",STUDENT[i].branch);
printf("%s\t\t",STUDENT[i].subject);
printf("%d\t\t",STUDENT[i].marks);
printf("\n");
}
getch();
}
// this program help us to making database.
No comments:
Post a Comment