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 (12k points)
Available when: Unlimited - Due to: Unlimited

retagged by | 59 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:162.158.79.43
©2016-2021

Related questions

6 like 0 dislike
3 answers
[Normal] Coding (C) - asked Oct 16, 2017 in Introduction to Computer Programming I (C) by thopd (12k points)
Available when: Unlimited - Due to: Unlimited
| 62 views
6 like 0 dislike
0 answers
[Normal] Coding (C) - asked Oct 16, 2017 in Introduction to Computer Programming I (C) by thopd (12k points)
Available when: Unlimited - Due to: Unlimited
| 62 views
11,163 questions
132,617 answers
129,948 comments
3,821 users