Structures:Structures provide a convenient method for handling related group of data of various data types.Structure definition: struct tag_name { data type member1; data type member2; … …}Example: struct library_books { char title[20]; char author[15]; int pages; float price; };The keyword struct informs the compiler for holding fields ( title, author, pages and price in the above example). All these are the members of the structure. Each member can be of same or different data type.The tag name followed by the keyword struct defines the data type of struct. The tag name library_books in the above example is not the variable but can be visualized as template for the structure. The tag name is used to declare struct variables.Ex: struct library_books book1,book2,book3; The memory space is not occupied soon after declaring the structure, being it a template. Memory is allocated only at the time of declaring struct variables, like book1 in the above example. The members of the structure are referred as - book1.title, book1.author, book1.pages, book1.price.UnionsUnions are like structures, in which the individual data types may differ from each other. All the members of the union share the same memory / storage area in the memory. Every member has unique storage area in structures. In this context, unions are utilized to observe the memory space. When all the values need not assign at a time to all members, unions are efficient. Unions are declared by using the keyword union , just like structures.Ex: union item { int code; float price;};The members of the unions are referred as - book1.title, book1.author, book1.pages, book1.price.
C
Topic: C basics
Describe structures and Union in brief.
Browse random answers:
What is the output of printf(“%d”)?
What is the difference between const char *p, char const *p, and char* const p ?
What's the difference between a null pointer, a NULL macro, the ASCII NUL character and a null string?
Can we get the remainder of a floating point division ?
How to write a swap( ) function which swaps the values of the variables using bitwise operators.
Is there any difference between the two representations?
main(){ int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){printf(" %d ",*p);++p; }}
Why doesn’t this code: a[i] = i++; work?
Write a pro gramme to show bubble sort on a set of 10 numbers?
How do I write code that executes certain function only at program termination?
Is NULL always defined as 0?
Find the output of followingmain(){float me = 1.1;double you = 1.1;if(me==you)printf("I love U");elseprintf("I hate U");}
What are storage memory, default value, scope and life of Automatic and Register storage class?
Nesting of loops in C may continue upto how many levels?
What are storage memory, default value, scope and life of Static and External storage class?
Write a function to swap any two numbers?
Which expression always return true? Which always return false?
Can we change the system date to some other date?
Give some explanation for "for" LOOP ON C LANGUAGE?
How to print 1 to 100 without using any conditional loop?
Can we get the process identification number of the current program?
C Program to print the following series:11 21 2 31 2 3 41 2 3 4 5
Write a pro gramme to show bubble sort on a set of 10 numbers?
How to set the system date through a C program ?
How can we find out prime numbers from 1 to 50?
Can we use scanf( ) function to scan a multiple words string through keyboard?
How to decide even and odd values without decision making loops?
Why the output of sizeof ( 'a' ) is 2 and not 1 ?
write c program fibbonaci series program?
Explain with an example the self-referential structure.
Describe structures and Union in brief.
How to extract the integer part and a fractional part of a floating point number?
How to build an expression trees ?
What's the difference between a null pointer, a NULL macro, the ASCII NUL character and a null string?
How do I get the time elapsed between two function calls ?
How do I write a program which can generate all possible combinations of numbers from 1 to one less than the given number ?
How can we read/write Structures from/to data files?
When should you use a type cast?
What are the advantages and disadvantages of external class?
Define recursion in C.
Differentiate Source Codes from Object Codes
How can you increase the size of a dynamically allocated array?
What is the difference between i++ and i+1 ?
How will you allocate memory to double a pointer?
What is the purpose of main( ) function ?
What is the simplest sorting method to use?
How to distinguish between a binary tree and a tree?
What is a stack ?
What are memory models?
How does C compiler store elements in a multi-dimensional array?
If the result of an _expression has to be stored to one of two variables, depending on a condition, can we use conditional operators as shown below?( ( i < 10 ) ? j : k ) = l * 2 + p ;
What are stdin, stdout, and stderr?
How do I use the function ldexp( ) in a program?
What value is yielded by a relational expression?
How do I print the contents of environment variables?
– Is the unary minus operator (-) the same as the subtraction operator (-)?
How do I convert a floating-point number to a string?
What can the %lu format specifier do?
What will be output when you will execute following c code?#include<stdio.h>void main(){ int check=2; switch(check){ case 1: printf("D.W.Steyn"); case 2: printf(" M.G.Johnson"); case 3: printf(" Mohammad Asif"); default: printf(" M.Muralidaran"); }}
Which of the following correctly shows the hierarchy of arithmetic operations in C?
What is automatic type promotion in c?
Which of the following is the correct usage of conditional operators used in C?
Declare a pointer which can point printf function in c.
Which of the following is the correct order if calling functions in the below code?
What are merits and demerits of array in c?
Which of the following are unary operators in C?
Is C a great language, or what? Where else could you write something like a+++++b ?
What will be output when you will execute following c code?#include<stdio.h>void main(){ int a=5,b=10,c=1; if(a&&b>c){ printf("cquestionbank"); } else{ break; }}a) cquestionbank b) It will print nothingc) Run time errord) Compilation errore) None of the above
How would you use the functions fseek(), freed(), fwrite() and ftell()?
What does static variable mean?
What is the simplest sorting method to use?
Difference between syntax vs logical error?
What will the preprocessor do for a program?
What is preincrement and post increment?
Way to minimize a last dimension regarding executable?
Write a program to interchange 2 variables without using the third one?
How much does static varied signify?
Way to minimize a last dimension regarding executable?
Difference between *p and **p?
Difference between pass by reference and pass by value?
What are enumerations?
Write a code for implementation of doubly linked list with use of single pointer in each node?
What is the use of typedef?
what are C tokens?
What are C identifiers?
What is preincrement and post increment?
What are bit fields? What is the use of bit fields in a Structure declaration?
Is it possible to have more than one main() function in a C program ?
Why n++ executes faster than n+1 ?
What will the preprocessor do for a program ?
What is a data type?
What will happen if any string in c is converted to integer explicitly?
Write a program to find the greatest of three numbers.
Write a program to check whether a given number is a prime.
Write a program to find the greatest among ten numbers.
Write a program to generate the fibonacci series
Write a program to display the multiplication table of a given number.
What is the difference between ‘break’ and ‘continue’ statements?
What is the difference between getchar and scanf functions for reading strings?
What is the difference between declaring a variable and defining a variable?