C Programming

prev next

Practise Exercise 9: Structures

Only use this if you have a forms compatible browser [Note: You must have an Internet connection in order to have these tests marked]


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

Structure 1


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

Structure 2


	type structure record { 
		loop : integer;
		word : array[0..4] of char;
		sum : real;
	};

Structure 3


	type record { 
		integer loop;
		char word[4];
		float sum;
	}

2. The statement which declares a structure variable called sample, defined from a structure of type struct record, is

3. The statment that assigns the value 10 to the field loop of the sample structure (which is of type struct record), is

4. The statement that prints out (using printf) the value of the word array of the sample structure is

5. The correct definition for a structure called birthdays, whose fields are a structure of type struct time called btime, and a structure of type struct date, called bdate, is

Structure 1


	birthdays {
		time btime;
		date bdate;
	};

Structure 2


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

Structure 3


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


To submit your comments, press this button:

To clear the form, press this button:


©Copyright B Brown. 1984-1998. All rights reserved.
prev next