https://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_C/Prog19&feed=atom&action=history
Curso de Programación en C/Prog19 - Historial de revisiones
2024-03-28T16:37:12Z
Historial de revisiones para esta página en el wiki
MediaWiki 1.32.1
https://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_C/Prog19&diff=3547&oldid=prev
Rrc: /* Prog19 */
2012-03-04T14:15:06Z
<p><span dir="auto"><span class="autocomment">Prog19</span></span></p>
<p><b>Página nueva</b></p><div>__NOTOC__<br />
* [[:#Prog19 | Prog19]]<br />
** [[:#Resultado | Resultado]]<br />
** [[:#Explicación | Explicación]]<br />
<br />
== Prog19 ==<br />
<br />
<syntaxhighlight lang="c" line="GESHI_FANCY_LINE_NUMBERS"><br />
<br />
/* Prog19.c -- Conversiones interesantes */<br />
<br />
#include <stdio.h><br />
<br />
#define PAGINAS 336<br />
#define PALABRAS 65618<br />
<br />
int main( void )<br />
{<br />
short num = PAGINAS;<br />
short mnum = -PAGINAS;<br />
<br />
printf( "num como short: %hd y como unsigned short: %hu\n", num, num );<br />
printf( "-num como short: %hd y como unsigned short: %hu\n", mnum, mnum );<br />
printf( "num como int: %i y como char: %c\n", num, num );<br />
printf( "PALABRAS como int: %d, como short: %hd, y como char: %c\n",<br />
PALABRAS, PALABRAS, PALABRAS ); <br />
return 0;<br />
}<br />
<br />
</syntaxhighlight><br />
<br />
=== Resultado ===<br />
<br />
[rrc@Pridd CClase]$ gcc -Wall -O2 -o Prog19 Prog19.c<br />
[rrc@Pridd CClase]$ ./Prog19<br />
num como short: 336 y como unsigned short: 336<br />
-num como short: -336 y como unsigned short: 65200<br />
num como int: 336 y como char: P<br />
PALABRAS como int: 65618, como short: 82, y como char: R<br />
[rrc@Pridd CClase]$ <br />
<br />
=== Explicación ===<br />
<br />
[[Category:Programación en C]]<br />
[[Category:CCabal]]<br />
[[Category:CursoC]]</div>
Rrc