We were given a source code to convert decimal to binary and octal.This is the source code that I am going to use the function Dec2BinOct() to return the values of the converted decimal.
#include<stdio.h>
int main()
{
unsigned long n, place=1, bin=0, r, o=0, place2=place;
printf("Conversion: Decimal to binary and octal.\n");
printf("Enter number: ");
scanf("%lu", &n);
printf("%lu is ", n);
for(unsigned long g = n; g != 0; place = place * 10) {
r = g % 2;
bin = bin + (r * place);
g = g / 2;
}
printf("%lu in Binary Form. \n", bin);
printf("%lu is ", n);
while (n != 0) {
o = o + (n % 8) * place2;
n = n / 8;
place2 = place2 * 10;
}
printf("%lu in Octal Form.\n\n", o);
return 0;
}
We were tasked to apply functions for our assignment and were required to use the function Dec2BinOct() as stated earlier, but our teacher told us that it is the minimum required function. I don't seem to get the right program after so many tries. I just needed some help and this is due tomorrow. I appreciate all of your help
Dec2BinOctfunction? We don't have access to your homework assignment.