diff options
| author | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
| commit | 4022e5c95210631e4aceb08eaf9d9071aa5aefc4 (patch) | |
| tree | a5922559836e45fb3459a3d070367912e1035b1a /tests/functional/78_decbinoct.sy | |
| download | rcc-master.tar.gz rcc-master.tar.xz | |
Diffstat (limited to 'tests/functional/78_decbinoct.sy')
| -rw-r--r-- | tests/functional/78_decbinoct.sy | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/functional/78_decbinoct.sy b/tests/functional/78_decbinoct.sy new file mode 100644 index 0000000..8cc78ba --- /dev/null +++ b/tests/functional/78_decbinoct.sy @@ -0,0 +1,31 @@ +int dec2bin(int a) +{ + int res; + int k; + int i; + int temp; + res=0; + k=1; + temp=a; + while(temp!=0) + { + i=temp%2; + res=k*i+res; + k=k*10; + temp=temp/2; + } + return res; + +} + +int main() +{ + int a; + a=400; + int res; + res=dec2bin(a); + putint(res); + res = 10; + putch(res); + return 0; +} |
