Skip to content

Tag Archives: C-Structure & Union

Prerequisite: Structure in C For writing in file, it is easy to write string or int to file using fprintf and putc, but you might… Read More
Flexible Array Member(FAM) is a feature introduced in the C99 standard of the C programming language. For the structures in C programming language from C99… Read More
In C11 standard of C, anonymous Unions and structures were added. Anonymous unions/structures are also known as unnamed unions/structures as they don’t have names. Since there… Read More
Predict the output of following C program #include<stdio.h> struct Point {   int x, y, z; };    int main() {   struct Point p1 = {.y… Read More
# include <iostream> # include <string.h> using namespace std;    struct Test {   char str[20]; };    int main() {   struct Test st1, st2;   strcpy(st1.str,… Read More
union test {     int x;     char arr[4];     int y; };    int main() {     union test t;     t.x = 0;     t.arr[1] = 'G';     printf("%s", t.arr);… Read More
union test {     int x;     char arr[8];     int y; };    int main() {     printf("%d", sizeof(union test));     return 0; } Predict the output of above… Read More
Which of the following operators can be applied on structure variables? (A) Equality comparison ( == ) (B) Assignment ( = ) (C) Both of… Read More
#include<stdio.h>  struct st  {      int x;      struct st next;  };       int main()  {      struct st temp;      temp.x = 10;      temp.next = temp;      printf("%d", temp.next.x); … Read More
Consider the following C declaration struct {      short s[5];     union {           float y;           long z;      }u;  } t; Assume that objects of the type short,… Read More
struct node  {     int i;     float j;  };  struct node *s[10]; The above C declaration define ‘s’ to be (GATE CS 2000) (A) An array,… Read More
Assume that size of an integer is 32 bit. What is the output of following program? #include<stdio.h> struct st {     int x;     static int y;… Read More
#include‹stdio.h› int main() {     struct site     {         char name[] = "GeeksQuiz";         int no_of_pages = 200;     };     struct site *ptr;     printf("%d ", ptr->no_of_pages);     printf("%s", ptr->name);     getchar();… Read More