Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- int main(){
- int x, c, bi[40];
- printf("Convert Decimal to Binary program\n");
- while (1)
- {
- printf(" Enter a positive integer number: ");
- fflush(stdin);
- scanf("%d",&x);
- c = 0;
- while (x>0) {
- bi[c] = x%2;
- x /= 2;
- c++;
- }
- printf(" Binary number: : ");
- for (int i = (c-1); i>0; i--) {
- printf("%d",bi[i]);
- }
- printf("\nPress any key to do another conversion.\n\n");
- getch();
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement