102k views
0 votes
Declare a structure whose tag name is Server and that contains the following fields: manufacturer, a string, model and serialnum, both also strings, year, an int, clockSpeed, a double, cores, an int, ram, an int and finally storage an int.

1 Answer

3 votes

Answer:

The answer to this question as follows :

Structure definition:

struct Server //define structure server.

{

string manufacturer;

//define string variable.

string model, serialnum; //define string variable.

int year;

//define integer variable.

double clockSpeed;

//define double variable.

int cores; //define integer variable.

int ram;

//define integer variable.

int storage;

//define integer variable.

};

Explanation:

Structure is a collection of heterogeneous(different type) elements. It is a user-define datatype which is available on the C/C++ programming language. To define any structure we use the struct keyword. The syntax of defining structure can be given as:

Syntax:

struct structure name

{

//define variables

//statements and code.

};

OR

struct structure name

{

//define variables

//statements and code.

}create structure variable;

In the above structure code, we define a structure that is "Server". In this structure, we define different types of variables that is " manufacturer, model, serialnum, year, clockSpeed, cores, ram, and storage". In this structure variable manufacturer, model and serialnum datatype are a string and clockSpeed datatype is double and variable year, cores, ram, and storage data type is an integer.

User Sjacob
by
8.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.