https://wiki.cabal.mx/index.php?title=Curso_de_Programaci%C3%B3n_en_C/Prog20&feed=atom&action=history
Curso de Programación en C/Prog20 - Historial de revisiones
2024-03-29T15:49:45Z
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/Prog20&diff=3747&oldid=prev
Archanasingh: /* Resultado */
2012-06-11T21:16:52Z
<p><span dir="auto"><span class="autocomment">Resultado</span></span></p>
<p><b>Página nueva</b></p><div>__NOTOC__<br />
* [[:#Prog20 | Prog20]]<br />
** [[:#Resultado | Resultado]]<br />
** [[:#Explicación | Explicación]]<br />
<br />
== Prog20 ==<br />
<br />
<syntaxhighlight lang="c" line="GESHI_FANCY_LINE_NUMBERS"><br />
<br />
/* Prog20.c -- Conversiones interesantes con floats */<br />
<br />
#include <stdio.h><br />
<br />
int main( void )<br />
{<br />
float n1 = 3.0;<br />
double n2 = 3.0;<br />
long n3 = 2000000000,<br />
n4 = 1234567890;<br />
<br />
printf( "Con conversiones naturales: %f %lf %ld %ld\n", n1, n2, n3, n4 );<br />
printf( "Con %%.1e: %.1e %.1e %.1e %.1e\n",<br />
n1, n2, n3, n4 );<br />
printf( "Con %%ld: %ld %ld %ld %ld\n",<br />
n1, n2, n3, n4 );<br />
<br />
return 0;<br />
}<br />
<br />
</syntaxhighlight><br />
<br />
=== Resultado ===<br />
<br />
[rrc@Pridd CClase]$ gcc -Wall -O2 -o Prog20 Prog20.c<br />
Prog20.c: In function ‘main’:<br />
Prog20.c:14: warning: format ‘%.1e’ expects type ‘double’, but argument 4 has type ‘long int’<br />
Prog20.c:14: warning: format ‘%.1e’ expects type ‘double’, but argument 5 has type ‘long int’<br />
Prog20.c:16: warning: format ‘%ld’ expects type ‘long int’, but argument 2 has type ‘double’<br />
Prog20.c:16: warning: format ‘%ld’ expects type ‘long int’, but argument 3 has type ‘double’<br />
[rrc@Pridd CClase]$ ./Prog20<br />
Con conversiones naturales: 3.000000 3.000000 2000000000 1234567890<br />
Con %.1e: 3.0e+00 3.0e+00 3.1e+46 6.6e-316<br />
Con %ld: 0 1074266112 0 1074266112<br />
[rrc@Pridd CClase]$<br />
<br />
=== Explicación ===<br />
<br />
[[Category:Programación en C]]<br />
[[Category:CCabal]]<br />
[[Category:CursoC]]</div>
Archanasingh