it can be written as
int day=31, month=3, year=2010;
if we want to keep the purchase details of a product with dates like for eg purchasing day, purchasing month, purchasing year so we need three more variables to declare like
int purchasing_day, purchasing_month, purchasing_year;
To keep the record of dates we need to access the above variables. Since they are related logically it would be good to have these accessed relatively. Here we make use of structures.
We can define a stucture named date consisting of three components namely day, month and year. The general syntax is
struct date
{
int day;
int month;
int year;
};
Now we can declare a new type in date declared in the structure date as
struct date today;
We need to use a special syntax to deal with structure variables. Structure members which includes the variables are accessed by . operator as
today.day=5; today.month=5; today.year=1998;


Sign In
Create Account

Back to top









