Skip to main content

STRUCTURE DATATYPE


Write a program to maintain the record of a student by using the structure datatype.

Let’s know something about structure. Structure is a collection of heterogenous element which is created as per requirement of the user. When we have to maintain the many type of values with in a body we need a datatype which can implement all the user define datatype then we can use structure.

Syntax: -

Struct structure name
{
Type member 1;
Type member 2;
          /* desired member can be declared */

};
Struct    structure name    structure variable name;

Program: -


#include<stdio.h>
struct student
{
int age;
char name[20];
float fee;
char address[30];
};
struct student s;
void main ()
{
clrscr();
printf("\n enter your age= ");
scanf("%d",& s.age);
printf("\n enter your name=");
scanf("%s", s.name );
printf("\n enter your fee=");
scanf("%f", &s.fee);
printf("\n enter your address=");
scanf("%s",s.address);
printf("\n your age is=%d", s.age);
printf("\n your name is =%s",s.name);
printf("\n your fee is =%f", s.fee);
printf("\n your address is =%s", s.address);
getch();
}

Output: -




Comments