Decimal.c - #include <stdio.h> int main int num,counter,array[100,remainder,binary,octal,hexa printf"Enter decimal here scanf%d&num binary = num octal =

# Decimal.c - #include <stdio.h> int main int...

• Notes
• 2

This preview shows page 1 - 2 out of 2 pages.

#include <stdio.h> int main() { int num,counter,array[100],remainder,binary,octal,hexa; printf("Enter decimal here: "); scanf("%d", &num); binary = num; octal = num; hexa = num; //* decimal to binary *// for (counter = 0; binary > 0; counter++){ remainder = binary % 2; binary = binary / 2; array[counter] = remainder; } counter = counter - 1; printf("The Value in Binary is: "); for (;counter >= 0; counter--){ printf("%d",array[counter]);} counter = 0; //* decimal to octal *// for (counter = 0; octal > 0; counter++){ remainder = octal % 8; octal = octal / 8; array[counter] = remainder; } counter = counter - 1; printf("\nThe Value in Octal is: "); for (;counter >= 0; counter--){

Subscribe to view the full document.

Unformatted text preview: printf(&quot;%d&quot;,array[counter]);} counter = 0; //* End *// //* decimal to hexadecimal *// for (counter = 0; hexa &gt; 0; counter++){ remainder = hexa % 16; hexa = hexa / 16; array[counter] = remainder; } counter = counter - 1; printf(&quot;\nThe Value in Hexa is: &quot;); for (;counter &gt;= 0; counter--){ if(array[counter] == 10){ printf(&quot;A&quot;); } else if(array[counter] == 11){ printf(&quot;B&quot;); } else if(array[counter] == 12){ printf(&quot;C&quot;); } else if(array[counter] == 13){ printf(&quot;D&quot;); } else if(array[counter] == 14){ printf(&quot;E&quot;); } else if(array[counter] == 15){ printf(&quot;F&quot;); } else printf(&quot;%d&quot;,array[counter]);} //* End *// }...
View Full Document

• Fall '18

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern