202k views
4 votes
In the following program, which of following variables are of the automatic storage class? int incsum (int *a, int b) { static int counterA) a and b

B) counter
C) None of the variables have automatic storage class
D) All variables have automatic storage class

User Velimir
by
7.1k points

1 Answer

2 votes

Final answer:

In the given program, 'a' and 'b' are of the automatic storage class, while 'counter' is static.

Step-by-step explanation:

In the program snippet that you've provided, the variables a and b are of the automatic storage class, whereas the variable named counter is declared with the static storage class. In C, variables that are declared inside a function without any storage class specifier are by default considered automatic (auto). This means they are automatically created when the function they are inside of is called, and destroyed when the function exits. The keyword static, however, indicates that the variable's lifetime is the entire execution of the program, so it's not automatic.

User Fayga
by
7.6k points