122k views
5 votes
Question B_1 (15 points) Please define (describe) local variables and how they are used in computer programming ( e.g. In C, C ). Please write clearly and use no more than 2 sentences. Question B_2 ( 15 points) Please define (describe) static variables and how they are used in computer programming ( e.g. In C, C ). Please write clearly and use no more than 2 sentences. Question

User Morris Lin
by
4.7k points

1 Answer

3 votes

Answer and Explanation:

Static variables are variables that still maintain their values outside the score which they are declared. They are declared with the static keyword

Example:

static int score = 30;

Local variables are variables whose scope are restricted to a block. Their values are restricted to the block which they are declared in.

Example:

void abd(){

int score;

}

score is a local variable to abcd() function

User Andrei Margeloiu
by
5.1k points