R
raghu
// Prog. to convert integer to binary
#include<stdio.h>
int main(void)
{
int i=4;
int j;
for(j=0;j<3;j++)
{
i=i%2;
printf("%d",i);
}
return 0;
}
Output should be 001 but output is 000
if i=3 ouput is 111.
Whats the problem in code?
I have compiled in Turbo C.
Please help.
#include<stdio.h>
int main(void)
{
int i=4;
int j;
for(j=0;j<3;j++)
{
i=i%2;
printf("%d",i);
}
return 0;
}
Output should be 001 but output is 000
if i=3 ouput is 111.
Whats the problem in code?
I have compiled in Turbo C.
Please help.