Buscar

What is the difference between global and local variables in C? Global variables are those declared outside the scope of functions, while local va...

What is the difference between global and local variables in C?

Global variables are those declared outside the scope of functions, while local variables are those declared at the beginning of a block and their scopes are restricted to the blocks in which they were declared.
Local variables are those declared outside the scope of functions, while global variables are those declared at the beginning of a block and their scopes are restricted to the blocks in which they were declared.
a) Only the first statement is correct.
b) Only the second statement is correct.
c) Both statements are correct.
d) Both statements are incorrect.

Essa pergunta também está no material:

Faculdade_de_Ciencias_Aplicadas_de_Casca
154 pág.

Ciências Aplicadas Universidade Estácio de SáUniversidade Estácio de Sá

Respostas

User badge image

Ed Verified user icon

A diferença entre variáveis globais e locais em C é a seguinte: Variáveis globais são declaradas fora do escopo das funções e podem ser acessadas por qualquer função dentro do programa. Elas têm uma vida útil durante toda a execução do programa. Variáveis locais são declaradas dentro do escopo de uma função ou bloco de código e só podem ser acessadas dentro desse escopo. Elas têm uma vida útil limitada ao tempo de execução desse bloco ou função. Portanto, a alternativa correta é: c) Ambas as afirmações estão corretas.

0
Dislike0

Responda

SetasNegritoItálicoSublinhadoTachadoCitaçãoCódigoLista numeradaLista com marcadoresSubscritoSobrescritoDiminuir recuoAumentar recuoCor da fonteCor de fundoAlinhamentoLimparInserir linkImagemFórmula

Para escrever sua resposta aqui, entre ou crie uma conta

User badge image

Continue navegando