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 15:20
This os integrated the processing power of windows nt with the easy-to-use gui of windows 98. windows 2000 windows 3.11 windows for workgroups windowa millennium edition
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
question
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
The basic work area of the computer is it screen that you when you first fire up your computer
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, 02.02.2021 22:20
question
Mathematics, 02.02.2021 22:20
question
Mathematics, 02.02.2021 22:20
question
Mathematics, 02.02.2021 22:20
question
Mathematics, 02.02.2021 22:20
question
Mathematics, 02.02.2021 22:20
question
English, 02.02.2021 22:20
Questions on the website: 13722361