subject

Create union integer with members char c, short s, int i and long b. Write a program that inputs the values of type char, short, int, and long and stores the values in union variables of type union integer. Each union variable should be printed as a char, a short, an int and a long. D the values always print correctly? Also create pseodocode or flowchart. Here is the feedback that I received when I originally turned this in:
I have the following concerns: You need to save your program file with a .c extension. You should declare your union above the main module and then utilize it from within this portion. You have declared the union and then created a function definition prior to entering the main() function.
Here is the original code provided by homework help: Thanks in advance
#include
union myUnion {
char c;
short s;
int i;
long l;
};
void print(myUnion u) {
printf("As a character: %c\n", u. c);
printf("As a short: %hd\n", u. s);
printf("As an int: %d\n", u. i);
printf("As a long: %ld\n\n", u. i);
}
int main() {
myUnion u;
printf("Please enter a character: ");
scanf("%c", &(u. c));
print(u);
printf("Please enter a short: ");
scanf("%hd", &(u. s));
print(u);
printf("Please enter an int: ");
scanf("%d", &(u. i));
print(u);
printf("Please enter a long: ");
scanf("%ld", &(u. l));
print(u);
return 0;

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:00
Search the web for two examples of digital art that you like. the examples must be from different mediums (example: one digital photo and one computer animation not two computer animations). compose an essay for each example you choose about why the piece appeals to you, and identify the medium used.
Answers: 1
question
Computers and Technology, 22.06.2019 10:50
Write a 3-4 page apa formatted paper comparing your organization’s it strategy with the best practices outlined in your course text. content should include, but not be limited to: developing and delivering on the it value, developing it strategy for the business value and linking it to business metrics. your paper should include an abstract and a conclusion and a reference page with 3-5 references
Answers: 1
question
Computers and Technology, 22.06.2019 11:30
Write a function so that the main program below can be replaced by the simpler code that calls function original main program: miles_per_hour = float( minutes_traveled = float( hours_traveled = minutes_traveled / 60.0 miles_traveled = hours_traveled * miles_per_hour print('miles: %f' % miles_traveled) sample output with inputs: 70.0 100.0 miles: 116.666667
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
The next button in the review section shows the next available comment. next slide with no comment. previous comment. edited comment.
Answers: 1
You know the right answer?
Create union integer with members char c, short s, int i and long b. Write a program that inputs the...
Questions
question
Mathematics, 24.07.2019 19:50
question
Geography, 24.07.2019 19:50
question
Mathematics, 24.07.2019 19:50
Questions on the website: 13722363