For each declared variable (aVar bVar cVar), print out the formated version as…
- User
For each declared variable (aVar bVar cVar), print out the formated version as hexadecimal, ascii, unsigned integer representa�on, and two’s complement nota�on. In a comment a�er these prin� statements, write a paragraph comparing and contras�ng your expected output.
#include <stdio.h>
int main(int argc, char * argv[]) { // If you run this program with YourFirstName and YourLastName // as extra arguments, argc would be 3, // First arg would be "./lab1". Second is "YourFirstName". // Third is "Your Last Name" // argv is an array containing all 3 args. Access them with [0 - 2]. // // If you run it with just YourFirstName as an extra element, the same // applies. argc is 2, being "./lab1" and "YourFirstName". argv is still // an array containing all arguments. // // If you run it with no extra arguments, argc is 1, argv is an array // with one entry of "./lab1". printf("Hello World\n"); printf("argc: \n", "%d"); // Loop through each argument for (int i = 0; i < argc; i++) { printf("argv[%d]: %s\n", i, argv[i]); } // Declaring 3 vars of different types
signed char aVar; unsigned int bVar; short cVar; // I'm choosing to use the size of the arguments unsigned int inputVal = sizeof(argv); // Assign based on input aVar = inputVal - 128; bVar = inputVal; cVar = inputVal; // Print the values of variables printf("Signed char variable: %d\n", aVar); printf("Unsigned int variable: %d\n". bBar); printf("Short variable: %d\n". cBar); // Binary meanings printf("Binary ret
- Assistant