N
naunetr
in program below
#include <stdio.h>
int main()
{
int id = 123, io = 0123, ih = 0x123;
long ld = 1234567L, lo = 01234567l, lh = 0X1234567L;
float f = 123.456f;
double d = 01234.56789L;
printf("id = %d\t%o\t%x\nio = %d\t%o\t%x\nih = %d\t%O\t%X\n",
id, id, id, io, io, io, ih, ih, ih);
printf("ld = %ld\t%lo\t%lx\nlo = %ld\t%lo\t%lx\nlh = %ld\t%lo\t%l\n",
ld, ld, ld, lo, lo, lo, lh, lh, lh);
printf("f = %lf\t%le\t%lg\nd = %lf\t%lE\t%lG\n", f, f, f, d, d, d);
return 0;
}
the output got is:
id = 123 173 7b
io = 83 123 53
ih = 291 %O 123
ld = 1234567 4553207 12d687
lo = 342391 1234567 53977
lh = 19088743 110642547 1234567
f = 123.456001 1.234560e+02 123.456
d = 1234.567890 1.234568E+03 1234.57
why is there a %O in line 3 instead of octal o/p expected?
and in line for d the last o/p is 1234.57. but %g is either %lf or %le
right? so if it is %lf then why is it 1234.57 instead of 1234.56789?
thanks
#include <stdio.h>
int main()
{
int id = 123, io = 0123, ih = 0x123;
long ld = 1234567L, lo = 01234567l, lh = 0X1234567L;
float f = 123.456f;
double d = 01234.56789L;
printf("id = %d\t%o\t%x\nio = %d\t%o\t%x\nih = %d\t%O\t%X\n",
id, id, id, io, io, io, ih, ih, ih);
printf("ld = %ld\t%lo\t%lx\nlo = %ld\t%lo\t%lx\nlh = %ld\t%lo\t%l\n",
ld, ld, ld, lo, lo, lo, lh, lh, lh);
printf("f = %lf\t%le\t%lg\nd = %lf\t%lE\t%lG\n", f, f, f, d, d, d);
return 0;
}
the output got is:
id = 123 173 7b
io = 83 123 53
ih = 291 %O 123
ld = 1234567 4553207 12d687
lo = 342391 1234567 53977
lh = 19088743 110642547 1234567
f = 123.456001 1.234560e+02 123.456
d = 1234.567890 1.234568E+03 1234.57
why is there a %O in line 3 instead of octal o/p expected?
and in line for d the last o/p is 1234.57. but %g is either %lf or %le
right? so if it is %lf then why is it 1234.57 instead of 1234.56789?
thanks