Try to do asap Complete the C code depends on the comments. #include #include // big_integer structure struct two_quadwords{ unsigned long lsq; long msq; }; // big_integer typedef typedef struct two_quadwords big_integer; // Union to store big integers as 16 characters or two quadwords union value{ big_integer binary; char hex[16]; }; // Prototypes of the methods to manipulate big integers // reads a big integer from string input and stores it in the union v // returns 0 if the hexadecimal number is invalid, 1 otherwise int read_big_integer(union value *v, char *input); // writes the value of b to standard output as 32 hex characters void write_big_integer(union value b); // performs b1 & b2 and stores the result in b1_and_b2 void and_big_integers(big_integer b1, big_integer b2, big_integer *b1_and_b2); // performs b1 | b2 and stores the result in b1_or_b2 void or_big_integers(big_integer b1, big_integer b2, big_integer *b1_or_b2); // performs b1 ^ b2 and stores the result in b1_xor_b2 void xor_big_integers(big_integer b1, big_integer b2, big_integer *b1_xor_b2); // performs ~b and stores the result in b void not_big_integer(big_integer *b); // performs b << k and stores the result in b void shift_big_integer_left(big_integer *b, unsigned k); // performs b >> k and stores the result in b void shift_big_integer_right(big_integer *b, unsigned k); // performs b1+b2 and stores the result in sum // returns 1 if overflow occurs, 0 otherwise int add_big_integers(big_integer b1, big_integer b2, big_integer *sum); // prints the message and value followed by the program usage message void print_usage(const char *message, const char* value); // main method int main(int argc, char* argv[]){ if(argc < 3 || argc > 4){ print_usage("Too many or too few arguments", ""); return 0; } if(argc == 3){ // NOT operation (3 arguments) if(strcmp(argv[1], "not")){ // check if operation is 'not' } return 0; } if(argc == 4){ //and, or, xor, sl, sr, add operations (4 arguments) } return 0; } // reads 32 hex characters // returns 0 if the hexadecimal number is invalid, 1 otherwise int read_big_integer(union value *v, char *input){ return 0; } // writes the 32 hex characters b to standard output void write_big_integer(union value b){ } // performs b1 & b2 and stores the result in b1_and_b2 void and_big_integers(big_integer b1, big_integer b2, big_integer *b1_and_b2){ } // performs b1 | b2 and stores the result in b1_or_b2 void or_big_integers(big_integer b1, big_integer b2, big_integer *b1_or_b2){ } // performs b1 ^ b2 and stores the result in b1_xor_b2 void xor_big_integers(big_integer b1, big_integer b2, big_integer *b1_xor_b2){ } // performs ~b and stores the result in b void not_big_integer(big_integer *b){ } // performs b << k and stores the result in b void shift_big_integer_left(big_integer *b, unsigned k){ } // performs b >> k and stores the result in b void shift_big_integer_right(big_integer *b, unsigned k){ } // performs b1+b2 and stores the result in sum // returns 1 if overflow occurs, 0 otherwise int add_big_integers(big_integer b1, big_integer b2, big_integer *sum){ return 0; } // prints the message and value followed by the program usage message void print_usage(const char *message, const char* value){ printf("%s %s\n", message, value); }
Try to do asap Complete the C code depends on the comments. #include #include // big_integer structure struct two_quadwords{ unsigned long lsq; long msq; }; // big_integer typedef typedef struct two_quadwords big_integer; // Union to store big integers as 16 characters or two quadwords union value{ big_integer binary; char hex[16]; }; // Prototypes of the methods to manipulate big integers // reads a big integer from string input and stores it in the union v // returns 0 if the hexadecimal number is invalid, 1 otherwise int read_big_integer(union value *v, char *input); // writes the value of b to standard output as 32 hex characters void write_big_integer(union value b); // performs b1 & b2 and stores the result in b1_and_b2 void and_big_integers(big_integer b1, big_integer b2, big_integer *b1_and_b2); // performs b1 | b2 and stores the result in b1_or_b2 void or_big_integers(big_integer b1, big_integer b2, big_integer *b1_or_b2); // performs b1 ^ b2 and stores the result in b1_xor_b2 void xor_big_integers(big_integer b1, big_integer b2, big_integer *b1_xor_b2); // performs ~b and stores the result in b void not_big_integer(big_integer *b); // performs b << k and stores the result in b void shift_big_integer_left(big_integer *b, unsigned k); // performs b >> k and stores the result in b void shift_big_integer_right(big_integer *b, unsigned k); // performs b1+b2 and stores the result in sum // returns 1 if overflow occurs, 0 otherwise int add_big_integers(big_integer b1, big_integer b2, big_integer *sum); // prints the message and value followed by the program usage message void print_usage(const char *message, const char* value); // main method int main(int argc, char* argv[]){ if(argc < 3 || argc > 4){ print_usage("Too many or too few arguments", ""); return 0; } if(argc == 3){ // NOT operation (3 arguments) if(strcmp(argv[1], "not")){ // check if operation is 'not' } return 0; } if(argc == 4){ //and, or, xor, sl, sr, add operations (4 arguments) } return 0; } // reads 32 hex characters // returns 0 if the hexadecimal number is invalid, 1 otherwise int read_big_integer(union value *v, char *input){ return 0; } // writes the 32 hex characters b to standard output void write_big_integer(union value b){ } // performs b1 & b2 and stores the result in b1_and_b2 void and_big_integers(big_integer b1, big_integer b2, big_integer *b1_and_b2){ } // performs b1 | b2 and stores the result in b1_or_b2 void or_big_integers(big_integer b1, big_integer b2, big_integer *b1_or_b2){ } // performs b1 ^ b2 and stores the result in b1_xor_b2 void xor_big_integers(big_integer b1, big_integer b2, big_integer *b1_xor_b2){ } // performs ~b and stores the result in b void not_big_integer(big_integer *b){ } // performs b << k and stores the result in b void shift_big_integer_left(big_integer *b, unsigned k){ } // performs b >> k and stores the result in b void shift_big_integer_right(big_integer *b, unsigned k){ } // performs b1+b2 and stores the result in sum // returns 1 if overflow occurs, 0 otherwise int add_big_integers(big_integer b1, big_integer b2, big_integer *sum){ return 0; } // prints the message and value followed by the program usage message void print_usage(const char *message, const char* value){ printf("%s %s\n", message, value); }
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section4.3: Nested If Statements
Problem 7E
Related questions
Question
Try to do asap
Complete the C code depends on the comments.
#include <stdio.h> | |
#include <string.h> | |
// big_integer structure | |
struct two_quadwords{ | |
unsigned long lsq; | |
long msq; | |
}; | |
// big_integer typedef | |
typedef struct two_quadwords big_integer; | |
// Union to store big integers as 16 characters or two quadwords | |
union value{ | |
big_integer binary; | |
char hex[16]; | |
}; | |
// Prototypes of the methods to manipulate big integers | |
// reads a big integer from string input and stores it in the union v | |
// returns 0 if the hexadecimal number is invalid, 1 otherwise | |
int read_big_integer(union value *v, char *input); | |
// writes the value of b to standard output as 32 hex characters | |
void write_big_integer(union value b); | |
// performs b1 & b2 and stores the result in b1_and_b2 | |
void and_big_integers(big_integer b1, big_integer b2, | |
big_integer *b1_and_b2); | |
// performs b1 | b2 and stores the result in b1_or_b2 | |
void or_big_integers(big_integer b1, big_integer b2, | |
big_integer *b1_or_b2); | |
// performs b1 ^ b2 and stores the result in b1_xor_b2 | |
void xor_big_integers(big_integer b1, big_integer b2, | |
big_integer *b1_xor_b2); | |
// performs ~b and stores the result in b | |
void not_big_integer(big_integer *b); | |
// performs b << k and stores the result in b | |
void shift_big_integer_left(big_integer *b, unsigned k); | |
// performs b >> k and stores the result in b | |
void shift_big_integer_right(big_integer *b, unsigned k); | |
// performs b1+b2 and stores the result in sum | |
// returns 1 if overflow occurs, 0 otherwise | |
int add_big_integers(big_integer b1, big_integer b2, big_integer *sum); | |
// prints the message and value followed by the program usage message | |
void print_usage(const char *message, const char* value); | |
// main method | |
int main(int argc, char* argv[]){ | |
if(argc < 3 || argc > 4){ | |
print_usage("Too many or too few arguments", ""); | |
return 0; | |
} | |
if(argc == 3){ // NOT operation (3 arguments) | |
if(strcmp(argv[1], "not")){ // check if operation is 'not' | |
} | |
return 0; | |
} | |
if(argc == 4){ //and, or, xor, sl, sr, add operations (4 arguments) | |
} | |
return 0; | |
} | |
// reads 32 hex characters | |
// returns 0 if the hexadecimal number is invalid, 1 otherwise | |
int read_big_integer(union value *v, char *input){ | |
return 0; | |
} | |
// writes the 32 hex characters b to standard output | |
void write_big_integer(union value b){ | |
} | |
// performs b1 & b2 and stores the result in b1_and_b2 | |
void and_big_integers(big_integer b1, big_integer b2, | |
big_integer *b1_and_b2){ | |
} | |
// performs b1 | b2 and stores the result in b1_or_b2 | |
void or_big_integers(big_integer b1, big_integer b2, | |
big_integer *b1_or_b2){ | |
} | |
// performs b1 ^ b2 and stores the result in b1_xor_b2 | |
void xor_big_integers(big_integer b1, big_integer b2, | |
big_integer *b1_xor_b2){ | |
} | |
// performs ~b and stores the result in b | |
void not_big_integer(big_integer *b){ | |
} | |
// performs b << k and stores the result in b | |
void shift_big_integer_left(big_integer *b, unsigned k){ | |
} | |
// performs b >> k and stores the result in b | |
void shift_big_integer_right(big_integer *b, unsigned k){ | |
} | |
// performs b1+b2 and stores the result in sum | |
// returns 1 if overflow occurs, 0 otherwise | |
int add_big_integers(big_integer b1, big_integer b2, big_integer *sum){ | |
return 0; | |
} | |
// prints the message and value followed by the program usage message | |
void print_usage(const char *message, const char* value){ | |
printf("%s %s\n", message, value); | |
} |
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr