|
|
| To initialize the members of a structure and display them. |
#include<stdio.h>
#include<conio.h>
void main ()
{
int i;
struct student
{
long int rollno;
char sex;
float height;
float weight;
} ;
struct student data [3] = {
{121,'m',5.7,59.8},
{122,'f',6.0,65.2},
{123,'m',6.2,75.5}
} ;
clrscr();
printf("THE INITIALIZED CONTENTS ARE : ");
for(i=0; i<=2; ++i)
{
printf("\n**RECORDARE :\n");
printf("%c\n",data[i] . sex);
printf("%f\n",data[i] . height);
printf("%f\n",data[i] . weight);
}
getch ();
}
|