6 like 0 dislike

Write a program to convert decimal number (<256) to binary. Use +-*/% operations only. Loops are not permitted

Example input:

50

Example output:

110010

 

[Normal] Coding (C) - asked in Introduction to Computer Programming I (C) by (11.3k points)
Available when: Unlimited - Due to: Unlimited

retagged by | 34 views

1 Answer

0 like 0 dislike
Hidden content!
#include<stdio.h>



int main() {
*** * *** * ***** *** n[8], a[8];
* * * * ** ** *** ** * **** ** ***** * &n[7]);
**** * * *** ** * ** * *
* ** *** ***** * * *** ***
* **** ** * * * * ** * * *
*** *** ** **** ***
** * * * * * ** * ** ** ***
******* ** ** * ** * *
** *** * ** * * ** *** * *
**** * ** * * * ** * ****
** * **** ***** * * *
*** * * ** * * *** * * * *****
* *** ** *** * **** *** ** *
* *** ** * ****** ** * ** **
** * * * * ** * *** ***
* ** * *** *** *** *
*** ** ** * * ** * * **
**** ** * * ** ****** * {
* ***** * * * *** *** ***** ** * * ** *** ******* * * ** * * ** a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]);

    }
* ** * * ****** if(a[1]!=0) {
** ** * * * * ** ***** * **** * ** ** *** **** * **** ** * **** ** ***** a[1], a[2], a[3], a[4], a[5], a[6], a[7]);

    }
* * ***** * ** ** * * ** if(a[2]!=0) {
*** *** *** * ** * ** * ** * ** ** * **** ** ***** **** * ** ** * * *** a[2], a[3], a[4], a[5], a[6], a[7]);
******* * *** * * ** * * *
** * *** ** *** if(a[3]!=0) {
* *** ** * ** ** * * * * **** * ******* * ** ** ** *** * ** *** * *** a[3], a[4], a[5], a[6], a[7]);
** * ** * ** *
*** * * ** * * ** *** if(a[4]!=0) {
* ********* ***** * * * *** * * ** * * ***** ****** **** * a[4], a[5], a[6], a[7]);

    }
****** **** * ****** **** if(a[5]!=0) {
** *** * * ******** * * ** * *** *** ** ** *** ** * ** * *** * *** *** a[5], a[6], a[7]);
* *** ** *** **
* ** * *** ** *** if(a[6]!=0) {
* *** * * ** * ***** *** **** ** ***** * *** * ** a[6], a[7]);
** *** * ** * * * * *
* ** ** * *** * * * ***** * ** if(a[7]!=0) {
*** * * *** ** * *** *** * ******* * ****** *** * * * * a[7]);
***** * *** *** ** **

}
answered by (-68 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.68.65.138
©2016-2020

Related questions

6 like 0 dislike
3 answers
[Normal] Coding (C) - asked Oct 16, 2017 in Introduction to Computer Programming I (C) by thopd (11.3k points)
Available when: Unlimited - Due to: Unlimited
| 43 views
6 like 0 dislike
0 answers
[Normal] Coding (C) - asked Oct 16, 2017 in Introduction to Computer Programming I (C) by thopd (11.3k points)
Available when: Unlimited - Due to: Unlimited
| 46 views
9,614 questions
94,666 answers
76,330 comments
2,928 users