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

retagged by | 91 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 (-114 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:35.170.64.36
©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 (12.1k points)
ID: 27167 - Available when: Unlimited - Due to: Unlimited
| 101 views
6 like 0 dislike
0 answers
[Normal] Coding (C) - asked Oct 16, 2017 in Introduction to Computer Programming I (C) by thopd (12.1k points)
ID: 27171 - Available when: Unlimited - Due to: Unlimited
| 103 views
11,846 questions
151,834 answers
155,104 comments
4,159 users