"union" Data Type What is the output of the following program? Why?

1 Answer

Answer :

#include  
main() {
typedef union {
int a;
char b[10];
float c;
}
Union;
Union x,y = {100};
x.a = 50;
strcpy(x.b,"hello");
x.c = 21.50;
printf("Union x : %d %s %f n",x.a,x.b,x.c);
printf("Union y : %d %s %f n",y.a,y.b,y.c);
}

Related questions

Description : What is the output of printf("%d")?

Last Answer : 1. When we write printf("%d",x); this means compiler will print the value of x. But as here, there is nothing after ï ½%dï ½ so compiler will show in output window garbage value. 2. When we ... an error without the proper number and type of arguments for things like printf(...) and scanf(...).

Description : String Processing --- Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba.

Last Answer : void PrintPermu (char *sBegin, char* sRest) { int iLoop; char cTmp; char cFLetter[1]; char *sNewBegin; char *sCur; int iLen; static int iCount; iLen = strlen(sRest); if (iLen == 2) { iCount++; ... printf("\nEnter a string:"); scanf("%s%*c",sIn); memset(s,0,255); PrintPermu(s, sIn); }

Description : Linked Lists -- Can you tell me how to check whether a linked list is circular?

Last Answer : Create two pointers, and set both to the start of the list. Update each as follows: while (pointer1) { pointer1 = pointer1->next; pointer2 = pointer2->next; if (pointer2) pointer2=pointer2->next ... before pointer1, or the item before that. Either way, its either 1 or 2 jumps until they meet.

Last Answer : Size of the final executable can be reduced using dynamic linking for libraries.

Description : printf() Function- What is the difference between "printf(...)" and "sprintf(...)"?

Last Answer : sprintf(...) writes data to the character array whereas printf(...) writes data to the standard output device.

Description : malloc() Function- What is the difference between "calloc(...)" and "malloc(...)"?

Last Answer : 1. calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block is initialized to 0. The total number of memory allocated will be (number_of_elements * ... calls malloc(...) in order to use the C+ + _set_new_mode function to set the new handler mode.

Description : What is C language?

Last Answer : The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX operating system. It has since spread to ... language for writing system software, though it is also used for writing applications. ...

Description : What is the full form of UDP a. Union Development Program b. User Data Program c. User Datagram Protocol d. Unified Datagram Provider

Last Answer : c. User Datagram Protocol

Description : What is the full form of UDP a. Union Development Program b. User Data Program c. User Datagram Protocol d. Unified Datagram Provider

Last Answer : c. User Datagram Protocol

Description : ____________ is the raw material used as input and __________ is the processed data obtained as output of data processing. a) Data, Instructions b) Instructions, Program c) Data, Program d) Program, Code

Last Answer : Answer: a Explanation: Data can be assumed as a raw material which , in turns after processing gives the desired output in the form of instructions. Further, a set of ordered and meaningful instructions is known as a program

Description : A memory in CPU that holds program instructions, input data, intermediate results and the output information produced during processing is __________ A. System B. Primary Memory C. Secondary Memory D. None of the above

Last Answer : B. Primary Memory

Description : What statement best describes President Kennedy foreign policy program with regard to the Soviet union?

Last Answer : Need answer