C Programming

Practise Exercise 9: Structures

1. Define a structure called record which holds an integer called loop, a character array of 5 elements called word, and a float called sum.


	struct record {
		int loop;
		char word[5];
		float sum;
	};

2. Declare a structure variable called sample, defined from a structure of type struct record.


	struct record sample;

3. Assign the value 10 to the field loop of the sample structure of type struct record.


	sample.loop = 10;

4. Print out (using printf) the value of the word array of the sample structure.


	printf("%s", sample.word );

5. Define a new structure called birthdays, whose fields are a structure of type struct time called btime, and a structure of type struct date, called bdate.


	struct birthdays {
		struct time btime;
		struct date bdate;
	};


©Copyright B Brown. 1984-1999. All rights reserved.