Study of structures - 2.

#include <stdio.h>
#include <string.h>

/* structure definition */
struct Car /* name of the structure */
{
char make[20], model[20]; /* member or element of the structure */
float hp, avg; /* member or element of the structure */
long int price; /* member or element of the structure */
};

int main(void)
{
/* Declaring and initializing struct variable */
struct Car santro = { "Hyundai", "Santro DLX", 12.5, 17, 385000 };

/* Display values in the members of the structure */
printf("\nDisplaying values : ");
printf("\nMade by : %s", santro.make);
printf("\nModel : %s", santro.model);
printf("\nHorse power : %f", santro.hp);
printf("\nAverage : %f", santro.avg);
printf("\nCost : %ld", santro.price);

printf("\nSize of structure variable : %u", sizeof(santro));

return 0;
}

No comments:

Post a Comment

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

......from.admin