This Post Contains A C Program For Conversion Of Decimal No Into
Binary No. With Correct Source Code & Output. This Program Is
Written, Compiled & Executed At Turbo C/C++3.0 Compiler & Will
Help You To Understand The Concept Of 'For-Loop' & 'While-Loop' From
C Language. It Is A Well-Structured Program With Proper Comments
Which Provides Step-By-Step Description Of Various Features Of The
Language In A Simple & Easy-To-Understand Way.
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C Program For Conversion Of Decimal No Into Binary No.
/* Declaration Of Header Files */
# include <stdio.h>
# include <conio.h>
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num, i, j, k, a[20], b[20];
clrscr();
/* Asking For The Input From User */
printf(" \n Enter Any No. : ");
scanf("%d", &Num);
/* Source Code For Conversion Of Decimal No Into Binary No */
i = 0;
while ( Num > 0 )
{
a[i] = Num % 2;
i++;
Num = Num / 2;
}
k = i - 1;
printf("\n\n");
for ( j = 0; j < i; j++ )
{
b[j] = a[k--];
printf("%d", b[j]);
}
getch();
}
/* End Of Main Program */
# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.
C Program For Conversion Of Decimal No Into Binary No.
/* Declaration Of Header Files */
# include <stdio.h>
# include <conio.h>
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num, i, j, k, a[20], b[20];
clrscr();
/* Asking For The Input From User */
printf(" \n Enter Any No. : ");
scanf("%d", &Num);
/* Source Code For Conversion Of Decimal No Into Binary No */
i = 0;
while ( Num > 0 )
{
a[i] = Num % 2;
i++;
Num = Num / 2;
}
k = i - 1;
printf("\n\n");
for ( j = 0; j < i; j++ )
{
b[j] = a[k--];
printf("%d", b[j]);
}
getch();
}
/* End Of Main Program */
No comments:
Post a Comment