From 5de9838a15a7da136121c17203c4dc0b1cf3e55f Mon Sep 17 00:00:00 2001 From: Rushil Umaretiya Date: Wed, 21 Feb 2024 14:59:01 -0500 Subject: [PATCH] formatted files --- f32.c | 2 +- negate2s.c | 15 ++++++++------- signed.c | 8 ++++---- twos.c | 15 +++++++-------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/f32.c b/f32.c index 07c3f57..2e74dff 100644 --- a/f32.c +++ b/f32.c @@ -1,4 +1,4 @@ -// PID: 730677144 +// PID: 730677144 // I pledge the COMP 211 honor code. #include diff --git a/negate2s.c b/negate2s.c index 3059c1d..6de0b26 100644 --- a/negate2s.c +++ b/negate2s.c @@ -1,12 +1,12 @@ -// PID: 730677144 +// PID: 730677144 // I pledge the COMP 211 honor code. -#include #include +#include #include -int main(int argc, char *argv[]) { - char input[33]; +int main(int argc, char* argv[]) { + char input[33]; char output[33] = {'\0'}; strncpy(input, argv[1], 32); @@ -14,14 +14,15 @@ int main(int argc, char *argv[]) { for (int i = 0; i < 32; i++) output[i] = (input[i] == '0') ? '1' : '0'; - + output[32] = '\0'; if (input[0] == '1') { int carry = 1; for (int i = 31; i >= 0 && carry; i--) { output[i] = (input[i] == '0') ? '1' : '0'; - if (input[i] == '0') carry = 0; + if (input[i] == '0') + carry = 0; } } else { int i = 31; @@ -32,7 +33,7 @@ int main(int argc, char *argv[]) { output[i] = '1'; } - + printf("%s\n", output); return EXIT_SUCCESS; } \ No newline at end of file diff --git a/signed.c b/signed.c index 3995f14..7466ebe 100644 --- a/signed.c +++ b/signed.c @@ -1,10 +1,10 @@ -// PID: 730677144 +// PID: 730677144 // I pledge the COMP 211 honor code. -#include #include +#include -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { int num = atoi(argv[1]); if (num < -32768 || num > 32767) { @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) { printf("0"); } } - + printf("\n"); return EXIT_SUCCESS; } diff --git a/twos.c b/twos.c index 9dcbcb7..b59d0ce 100644 --- a/twos.c +++ b/twos.c @@ -1,12 +1,12 @@ -// PID: 730677144 +// PID: 730677144 // I pledge the COMP 211 honor code. -#include #include +#include -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { int num = abs(atoi(argv[1])); - char out[17] = "\0"; + char out[17] = "\0"; if (num > 65535) { printf("not possible\n"); @@ -15,12 +15,11 @@ int main(int argc, char *argv[]) { for (int i = 15; i >= 0; i--) { if (num >= (1 << i)) { - out[15-i] = '1'; + out[15 - i] = '1'; num -= (1 << i); } else { - out[15-i] = '0'; + out[15 - i] = '0'; } - } if (argv[1][0] == '-') { @@ -40,7 +39,7 @@ int main(int argc, char *argv[]) { break; } } - } + } printf("%s\n", out);