Você está na página 1de 2

5/18/23, 4:55 PM Google Tradutor

Tradutor

Texto Imagens Sites

PORTUGUÊS swap_horiz INGLÊS

Conforme Soffner (2013) a utilização funções com de clear


passagem de parâmetros por referência está diretamente
ligada aos conceitos de ponteiro e endereço de memória. A
ideia da técnica é análoga a passagem por valores, ou seja, a
função será definida de modo a receber certos parâmetros e
“quem” faz a chamada do método deve informar esses
argumentos. Entretanto, o comportamento e o resultado são
diferentes. Na passagem por referência não será criada uma
cópia dos argumentos passados, na verdade, será passado o
endereço da variável e função irá trabalhar diretamente com os
valores ali armazenados. Observe o programa a seguir:
#include <stdio.h>int testar (int* n1, int* n2){ *n1 = -1; *n2 = -2;
printf("\n\n Valores dentro da função testar(): "); printf("\n n1 =
%d e n2 = %d",*n1,*n2); return 0;}int main ( ){int n1 = 10;int n2 =
20;printf("\n\n Valores antes de chamar a função: ");printf("\n
n1 = %d e n2 = %d",n1,n2);testar(&n1, &n2);printf("\n\n Valores
depois de chamar a função: ");printf("\n n1 = %d e n2 =
%d",n1,n2);return 0;}
Analisando o contexto e o programa apresentado, assinale a
alternativa correta quanto ao uso dos sinais * (asterisco) e & (e
1.187 / 5.000

According to Soffner (2013) the use of functions with passing star_border


parameters by reference is directly linked to the concepts of
pointer and memory address. The idea of the technique is
analogous to passing by values, that is, the function will be
defined in order to receive certain parameters and the “who”
calls the method must inform these arguments. However, the
behavior and the result are different. When passing by
reference, a copy of the passed arguments will not be created,
in fact, the address of the variable will be passed and the
https://translate.google.com/?sl=pt&tl=en&text=Conforme Soffner (2013) a utilização funções com de passagem de parâmetro… 1/2
5/18/23, 4:55 PM Google Tradutor

function will work directly with the values stored there. Watch
the followingTradutor
program:
#include <stdio.h>int test (int* n1, int* n2){ *n1 = -1; *n2 = -2;
printf("\n\n Values inside test() function: "); printf("\n n1 = %d
and n2 = %d",*n1,*n2); return 0;}int main ( ){int n1 = 10;int n2 =
20;printf("\n\n Values before calling the function: ");printf("\n n1
= %d and n2 = %d" ,n1,n2);test(&n1, &n2);printf("\n\n Values
after calling the function: ");printf("\n n1 = %d and n2 =
%d",n1,n2); return 0;}
Analyzing the context and the program presented, mark the
correct alternative regarding the use of the signs * (asterisk)
and & (ampersand):

Enviar feedback

Histórico Salvas Contribuir

https://translate.google.com/?sl=pt&tl=en&text=Conforme Soffner (2013) a utilização funções com de passagem de parâmetro… 2/2

Você também pode gostar