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("\nShort: "); scanf("%hd", &inputs.s);
printf("Short: %hd", inputs.s);
printf("\nInteger: "); scanf("%d", &inputs.i);
printf("Output: %d", inputs.i);
printf("\nLong: "); 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
}
Explanation:
This defines the union function
<em>union myUnion{ char c; short s; int i; long l; };</em>
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("\nShort: "); scanf("%hd", &inputs.s);
This prints the short input
printf("Short: %hd", inputs.s);
This prompts and gets input for integer variable
printf("\nInteger: "); scanf("%d", &inputs.i);
This prints the integer input
printf("Output: %d", inputs.i);
This prompts and gets input for long variable
printf("\nLong: "); scanf("%ld", &inputs.l);
This prints the long input
printf("Long: %ld", inputs.l);
return 0;
}