Answer:
The updated program in C is as follows:
#include <stdio.h>
union myUnion{ char c; short s; int i; long l; };
int main(){
union myUnion inputs;
printf("Character: "); scanf("%c", &inputs.c);
printf("Output: %c", inputs.c);
printf("\\Short: "); scanf("%hd", &inputs.s);
printf("Short: %hd", inputs.s);
printf("\\Integer: "); scanf("%d", &inputs.i);
printf("Output: %d", inputs.i);
printf("\\Long: "); scanf("%ld", &inputs.l);
printf("Long: %ld", inputs.l);
return 0;
}
The pseudocode is as follows:
Function union myUnion {
character; short; int; long
}
main() {
myUnion inputs;
Input inputs.c; Print inputs.c
Input inputs.s; Print inputs.s
Input inputs.i; Print inputs.i;
Input inputs.l; Print inputs.l
}
Step-by-step explanation:
This defines the union function
union myUnion{ char c; short s; int i; long l; };
The main begins here
int main(){
This calls the union function to main
union myUnion inputs;
This prompts and gets input for character variable
printf("Character: "); scanf("%c", &inputs.c);
This prints the character input
printf("Output: %c", inputs.c);
This prompts and gets input for short variable
printf("\\Short: "); scanf("%hd", &inputs.s);
This prints the short input
printf("Short: %hd", inputs.s);
This prompts and gets input for integer variable
printf("\\Integer: "); scanf("%d", &inputs.i);
This prints the integer input
printf("Output: %d", inputs.i);
This prompts and gets input for long variable
printf("\\Long: "); scanf("%ld", &inputs.l);
This prints the long input
printf("Long: %ld", inputs.l);
return 0;
}