A little C sip

Here is a code:

#include “stdio.h”
int main()
{
float a=4;
int i=2;
printf(“%f\t%d”,i/a,i/a);
printf(“\n%d\t%f”,i/a,i/a);
return 0;
}

i expected the output to be:

0.500000 0
0 0.500000

but unfortunately..itsn’t not the same. The reason is the first printf conversion is messed up a little leading the second printf to not work in a predictable way. Go, get it run and see!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s