150k views
4 votes
Write C statement(s) that declare the following variables: num1, num2, num3, and average of type int.

A. int num1, num2, num3, average;
B. average, num1, num2, num3 = int;
C. declare num1, num2, num3, average as int;
D. int average; int num1, num2, num3;

User Lekhnath
by
8.1k points

1 Answer

3 votes

Final answer:

The correct C statement to declare variables of type int is 'int num1, num2, num3, average;'. This efficiently declares all four variables in one go, following proper C syntax. Option A is correct.

Step-by-step explanation:

The correct C statement for declaring the variables num1, num2, num3, and average of type int is as follows:

A. int num1, num2, num3, average;

This statement declares all four variables in one line, which is efficient and concise. Each variable can now be used to store integer values. This is standard syntax in the C programming language when declaring multiple variables of the same type. Declaration B, C, and D are not correct syntax for variable declaration in C.

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