A
asit
plz fix the bug...
#include <stdio.h>
int main()
{
char ch;
char i;
printf("Enter an unsigned char : ");
scanf("%d",&ch);
printf("You have entered : %ud\n",ch);
printf("binary representation...\n");
for(i=sizeof(char)*8-1;i>=0;i--)
((1<<i)&ch) ? printf("1 "): printf("0 ");
printf("\n");
return 0;
}
when i run it, if 130 is entered..it should show 130...but its not
showig ???
and also why the error segmentation fault comes ??
#include <stdio.h>
int main()
{
char ch;
char i;
printf("Enter an unsigned char : ");
scanf("%d",&ch);
printf("You have entered : %ud\n",ch);
printf("binary representation...\n");
for(i=sizeof(char)*8-1;i>=0;i--)
((1<<i)&ch) ? printf("1 "): printf("0 ");
printf("\n");
return 0;
}
when i run it, if 130 is entered..it should show 130...but its not
showig ???
and also why the error segmentation fault comes ??