TopBottom

Followers



Click on more
SUBSCRIBE

Enter your email address:

Delivered by FeedBurner



VIDEO

Announcement: wanna exchange links? contact me at ravikrak@yahoo.com

Output Of Integer Numbers in C lang

Posted by Ravi Kumar at Sunday, September 11, 2011
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Output Of Integer Numbers in C language:

The format specification for printing an integer
number is %wd where w specifies the minimum field width
for the output. However if a number is greater than the
specified field width,it will be printed in full. Overr
iding the minimum specification d specifies the value to
be printed is an
integer.
The following examples illustrate the output of the
number 9876 under different formates:
Format - Output
printf("%d", 9876) 9 8 7 6
printf("%6d",9876) S S 9 8 7 6
printf("%2d",9876) 9 8 7 6
printf("%-6d",9876) 9 8 7 6 S S
printf("%06d",9876) 0 0 9 8 7 6

It is possible to force the printing to be left-
justified by placing a minus sign directly after the %
character.

Program: The output of integer number under various formats
/* printing of integer numbers*/
main()
{
int m=12345;
long n=987654;
printf("%d\n",m);
printf("%10d\n",m);
printf("%010d\n",m);
printf("-10d\n",m);
printf("%10ld\n",n);
printf("%10ld \n",-n);
}

output: 12345
12345
000012345
12345
987654
- 987654

Share |

Labels:

0 comments:

Post a Comment