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 | 13 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.69.63.13
©2016-2019

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
| 11 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
| 13 views
9,100 questions
79,740 answers
55,635 comments
2,475 users