Ask Question

How would you consolidate the following declaration statements into one statement?

int x = 7;

int y = 16;

int z = 28;

A.

int x = 7; y = 16; z = 28;

B.

int x = 7 y = 16 z = 28;

C.

int x, y, z = 7, 16, 28

D.

int x = 7, y = 16, z = 28;

+1
Answers (1)
  1. 27 July, 13:07
    0
    Correct option is (D) that is int x = 7, y = 16, z = 28;.

    Explanation:

    To initialize multiple variables in a single statement, we use this syntax "data type variable=value, variable=value, variable=value; ". here data type should be same for all the variable. All the variables are separated by ",". In this way we can initialize many variables in a single statement, but all the variables must have same data type. In option A,"; " is used to separate the variables but this is used to end a statement. In option B, nothing used to separate all the variables and in option C, there is no "; " to end the statement.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “How would you consolidate the following declaration statements into one statement? int x = 7; int y = 16; int z = 28; A. int x = 7; y = 16; ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers