#include <stdio.h>
int main(void)
{
int a, num1 = 10000, num2 = 1000, num3 = 100, num4 = 10, num5 = 1,
result1, result2, result3, result4, result5,
num2_1, num3_1, num4_1, num5_1;
printf("Enter a five digit number: ");
scanf("%d", &a);
result1 = a / num1;
num2_1 = a % num1;
result2 = num2_1 / num2;
num3_1 = num2_1 % num2;
result3 = num3_1 / num3;
num4_1 = num3_1 % num3;
result4 = num4_1 / num4;
num5_1 = num4_1 % num4;
result5 = num5_1 / num5;
printf("%d\t%d\t%d\t%d\t%d\t\n", result1, result2, result3, result4, result5);
return 0;
}
#include <stdio.h>
int main(void)
{
int a, num, num2 = 10000;
printf("Enter a five digit number: ");
scanf("%d", &a);
while(a != 0) {
num = a / num2;
a %= num2;
num2 /= 10;
printf("%d\t", num);
}
printf("\n");
return 0;
}
/*Program for converting a binary number to decimal*/
/*Created by kacToHbI4*/
#include <stdio.h>
int main(void)
{
int a,
num1 = 10000000, num2 = 1000000, num3 = 100000, num4 = 10000, num5 = 1000, num6 = 100, num7 = 10, num8 = 1,
num2_1, num3_1, num4_1, num5_1, num6_1, num7_1, num8_1,
result, result1, result2, result3, result4, result5, result6, result7, result8;
printf("Enter a eight-digit binary number: ");
scanf("%d", &a);
/*****Block for separates the number into its individual digits.*****/
/********************************************************************/
result1 = a / num1;
num2_1 = a % num1;
result2 = num2_1 / num2;
num3_1 = num2_1 % num2;
result3 = num3_1 / num3;
num4_1 = num3_1 % num3;
result4 = num4_1 / num4;
num5_1 = num4_1 % num4;
result5 = num5_1 / num5;
num6_1 = num5_1 % num5;
result6 = num6_1 / num6;
num7_1 = num6_1 % num6;
result7 = num7_1 / num7;
num8_1 = num7_1 % num7;
result8 = num8_1 / num8;
/*******The algorithm for converting a binary number to decimal******/
/********************************************************************/
if(result8 != 0) {
result8 = 1;
} if(result7 != 0) {
result7 = 2;
} if(result6 != 0) {
result6 = 4;
} if(result5 != 0) {
result5 = 8;
} if(result4 != 0) {
result4 = 16;
} if(result3 != 0) {
result3 = 32;
} if(result2 != 0) {
result2 = 64;
} if(result1 != 0) {
result1 = 128;
}
result = result8 + result7 + result6 + result5 + result4 + result3 + result2 + result1;
printf("Decimal number: %d\n", result);
return 0;
}