What is a Decimal number?
- A decimal numeral refers generally to the notation of a number in the decimal numeral system.
- The system consist these 0,1,2,3,4,5,6,7,8,9 numbers.
- Eg- 5,50,95,1452 .
What is a Binary number?
- A Binary numeral refers generally to the notation of a number in the Binary numeral system.
- The system consists of these 0,1 numbers.
- Eg- 101, 001,111,0101
C Program to convert Decimal to Binary Number
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- {
- int a[10];
- int n;
- int i;
- printf("Enter decimal number \n");
- scanf("%d",&n);
- for(i=0;n>0;i++)
- {
- a[i]=n%2;
- n=n/2;
- }
- printf("\nBinary number is ");
- for(i=i-1;i>=0;i--)
- {
- printf("%d",a[i]);
- }
- return 0;
- }
0 Comments
If you have any doubts, Please let me know