Study of structures - 3.

#include <stdio.h>

/* structure definition */
struct student
{
int rollno;
char name[20];
float percent;
};

typedef struct student stu;

int main(void)
{
/* Declaring a struct variable */
stu s;

/* Accept student info and store in elements of variable s */
printf("\nEnter info for student : \n");
printf("\nEnter Roll No : ");
scanf("%d", &s.rollno);

printf("Enter Name : ");
fflush(stdin);
gets(s.name);

printf("Enter Percentage : ");
scanf("%f", &s.percent);

/* Display student info ie. elements of variable s */
printf( "\nDisplaying student info : \n");
printf( "\nName : %s", s.name);
printf( "\nRoll No : %d", s.rollno);
printf( "\nPercentage : %f", s.percent);

printf("\n\nSize of s : %u", sizeof(s));

return 0;
}

No comments:

Post a Comment

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin