6 like 0 dislike
754 views

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 | 754 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 (-120 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:172.70.194.137
©2016-2025

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
| 1k 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
| 666 views
12,783 questions
183,442 answers
172,219 comments
4,824 users