The intent of this page is to collection the best program and help programmers to find good blog posts to read. Some of these blogs may not be written by Java developers, but Java developers should find it useful or interesting. Reading those blogs should be fun and often bring some fresh ideas

Saturday, February 8, 2020

C program : How to convert Negative Decimal Number into Binary number

#include<stdio.h>
char * Decimal_to_Binary(int no){
int i;
static char Buffer[17];
for(i=8*sizeof(int)-1; i>=0; i--)
Buffer[15-i]=(no>>i&1)+'0';
return Buffer;
}
void main(){
int no;
printf("Enter the Negative Decimal Number: ");
scanf("%d",&no);
printf("%s",Decimal_to_Binary(no));
}

output:

Enter the Negative Decimal Number:  -1
1111 1111 1111 1111


2 comments:

If you have any doubt . Please let me know

String Operation

String Operation Using collection Framework Sorting Order  public static void sortAccending(String s) { char[] arr = s.toCharArray(); ...

Adbox