-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdectobin.c
More file actions
29 lines (26 loc) · 773 Bytes
/
Copy pathdectobin.c
File metadata and controls
29 lines (26 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*-------------------------------------------------------------------------------------------------------------------------------
dectobin.c
Program to convert an integer number to a binary number
DIVYA RAJ K
22-09-2018
---------------------------------------------------------------------------------------------------------------------------------*/
#include<stdio.h>
#include<math.h>
int main()
{
int Num,N,Rem,i=0;
long int Binary=0;
//system("clear");
printf("Program to convert an integer number to a binary number\n\n");
printf("Enter an integer number: ");
scanf("%d",&Num);
N=Num;
while(Num>=1){
Rem=Num%2;
Binary=Rem*pow(10,i)+Binary;
Num=Num/2;
i++;
}
printf("\nThe binary equivalent of the decimal number %d is %ld",N,Binary);
return 0;
}