QUIZ – ADVANCED DATA TYPE
Write a single statement or a set of statement to accomplish each of the following.
- Define a structure called Komputer containing double variable harga and char array model whose values may be as long as 25 characters.
[3 marks]
struct komputer {
double harga;
char model[25];
};
- Declare variable ACER to be of type Komputer and array HP[10] to be of type Komputer.
[3 marks]
struct komputer ACER, HP[10];
- Read a PC Price and a PC model from the keyboard into the individual members of variable ACER.
[2 marks]
cin>>ACER.harga;
cin>>ACER.model;
- Assign the member values of variable ACER to element 3 of array HP.
[2 marks]
HP[2].harga = ACER.harga;
HP[2].model = ACER.model; //strcpy(HP[2].model, ACER.model);
No comments:
Post a Comment