5.3: Ejercicios
- Page ID
- 82263
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)
Ejercicio\(\PageIndex{1}\)
Supongamos que una función declara una variable así: static int x=0;
La función incrementa la variable y luego imprime su valor. ¿Qué imprime la función en la décima llamada a la función? ¿Cómo cambiaría esto si no se usara la palabra clave static
?
Ejercicio\(\PageIndex{2}\)
Considere el siguiente fragmento de código:
void doug( void ) { int x=0; x=x+1; printf( “%d\n”, x ); } void dinsdale( void ) { int x=20; x=x+1; printf( “%d\n”, x ); }
Supongamos que llama a doug ()
cinco veces seguidas y luego llama a dinsdale ()
cinco veces seguidas. ¿Cómo sería la salida resultante?