Professional Documents
Culture Documents
EX - NO:10 Date: Conversion of Decimal Number Into Other Bases
EX - NO:10 Date: Conversion of Decimal Number Into Other Bases
DATE:
AIM:
To write a C Program to Convert the given decimal number into binary, octal and
hexadecimal numbers using user defined functions.
ALGORITHM:
1. Start
2. Declare variables.
4. Develop the procedure for conversion of different base by modulus and divide operator.
6. Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
char temp;
temp = *s1;
*s1 = *s2;
*s2 = temp;
{
int start = 0;
swap(&str[start], &str[end]);
start++;
end--;
int i = 0;
if (num == 0)
str[i++] = '0';
str[i] = '\0';
return str;
while (num != 0)
num = num/base;
reverse(str, i);
return str;
void main()
char str[100];
int n;
clrscr();
scanf("%d",&n);
getch();
RESULT:
Thus a C Program for conversion of decimal number into other bases was executed and
the output was obtained.