0% found this document useful (0 votes)
51 views22 pages

Structure Prob112

Uploaded by

naneet yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views22 pages

Structure Prob112

Uploaded by

naneet yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Technical Training (Structure)

#include<stdio.h>
struct student Consider the following C program & Choose the correct
{ option(Assume Integer Size 8 Byte) .
int x; A. 8 B. 16
static int y;
}; C. Syntax Error D. Compiler error

int main()
{
printf("%d", sizeof(struct student));
return 0;
}
Technical Training (Structure)
#include<stdio.h>
struct student Consider the following C program & Choose the correct
{ option(Assume Integer Size 8 Byte) .
int x;
A. 8 B. 16
static int y;
}; C. Syntax Error D. Compiler error

int main()
{
printf("%d", sizeof(struct student));
return 0;
}
Technical Training (Structure)
struct {
short arr[10]; Consider the following C program & Choose the correct
union { option(Assume short 2B,float 4B,long 8B what is Memory
requirement for variable y) .
float a;
long b; A. 28 B. 32
}x;
C. 22 D. Compiler error
} y;
Technical Training (Structure)
struct {
short arr[10]; Consider the following C program & Choose the correct
union { option(Assume short 2B,float 4B,long 8B what is Memory
requirement for variable y) .
float a;
long b; A. 28 B. 32
}x;
C. 22 D. Compiler error
} y;
Technical Training (Structure)
#include<stdio.h>
struct student Consider the following C program & Choose the correct
{ option.
int x; A. 10 B. 16
struct student next;
}; C. Syntax Error D. Compiler error

int main()
{
struct student temp;
temp.x = 10;
temp.next = temp;
printf("%d", temp.next.x);
return 0;
}
Technical Training (Structure)
#include<stdio.h>
struct student Consider the following C program & Choose the correct
{ option.
int x; A. 10 B. 16
struct student next;
}; C. Syntax Error D. Compiler error

int main()
{
struct student temp;
temp.x = 10;
temp.next = temp;
printf("%d", temp.next.x);
return 0;
}
Technical Training (Structure)
#include<stdio.h>
union test Consider the following C program & Choose the correct
{ option.
int x; A. Nothing Printed B. garbage
char arr[4];
int y; C. x D. Compiler error
};

int main()
{
union test t;
t.x = 0;
t.arr[1] = ‘x';
printf("%s", t.arr);
return 0;
}
Technical Training (Structure)
#include<stdio.h>
union test Consider the following C program & Choose the correct
{ option.
int x; A. Nothing printed B. garbage
char arr[4];
int y; C. x D. Compiler error
};

int main()
{
union test t;
t.x = 0;
t.arr[1] = ‘x';
printf("%s", t.arr);
return 0;
}
Technical Training (Structure)
#include<stdio.h>
struct Point Consider the following C program & Choose the correct
{ option.
int x, y, z; A. 2 0 1 B. 0 1 2
};
int main() C. 1 0 2 D. Compiler error
{
struct Point p1 = {.y = 0, .z = 1, .x = 2};
printf("%d %d %d", p1.x, p1.y, p1.z);
return 0;
}
Technical Training (Structure)
#include<stdio.h>
struct Point Consider the following C program & Choose the correct
{ option.
int x, y, z; A. 2 0 1 B. 0 1 2
};
int main() C. 1 0 2 D. Compiler error
{
struct Point p1 = {.y = 0, .z = 1, .x = 2};
printf("%d %d %d", p1.x, p1.y, p1.z);
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct date { What is the size of date in byte Assume that unsigned int
unsigned int d; takes 32 bit.
unsigned int m; A. 12 B. 24
unsigned int y;
}; C. 4 D. Compiler error

int main()
{
printf("Size of date is %lu bytes\n",
sizeof(struct date));
struct date dt = { 04, 01, 2021 };
printf("Date is %d/%d/%d", dt.d, dt.m, dt.y);
}
Technical Training (Structure)
#include <stdio.h>
struct date { What is the size of date in byte Assume that unsigned int
unsigned int d; takes 32 bit.
unsigned int m; A. 12 B. 24
unsigned int y;
}; C. 4 D. Compiler error

int main()
{
printf("Size of date is %lu bytes\n",
sizeof(struct date));
struct date dt = { 04, 01, 2021 };
printf("Date is %d/%d/%d", dt.d, dt.m, dt.y);
}
Technical Training (Structure)
#include <stdio.h>
struct date { What is the size of date in byte Assume that unsigned int
unsigned int d : 5; takes 32 bit.
unsigned int m : 4; A. 8 B. 24
unsigned int y;
}; C. 12 D. Compiler error

int main()
{
printf("Size of date is %lu bytes\n",
sizeof(struct date));
struct date dt = { 04, 01, 2021 };
printf("Date is %d/%d/%d", dt.d, dt.m, dt.y);
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct date { What is the size of date in byte Assume that unsigned int
unsigned int d : 5; takes 32 bit.
unsigned int m : 4; A. 8 B. 24
unsigned int y;
}; C. 12 D. Compiler error

int main()
{
printf("Size of date is %lu bytes\n",
sizeof(struct date));
struct date dt = { 04, 01, 2021 };
printf("Date is %d/%d/%d", dt.d, dt.m, dt.y);
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct date { What is the output when date is printed Assume that
int d : 5; unsigned int takes 32 bit.
int m : 4; A. 04/01/2021 B. -1/-4/2021
int y;
}; C. 4/1/2021 D. Compiler error

int main()
{
printf("Size of date is %lu bytes\n",
sizeof(struct date));
struct date dt = { 31, 12, 2021 };
printf("Date is %d/%d/%d", dt.d, dt.m, dt.y);
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct date { What is the output when date is printed . Assume that
int d : 5; unsigned int takes 32 bit.
int m : 4; A. 04/01/2021 B. -1/-4/2021
int y;
}; C. 4/1/2021 D. Compiler error

int main()
{
printf("Size of date is %lu bytes\n",
sizeof(struct date));
struct date dt = { 31, 12, 2021 };
printf("Date is %d/%d/%d", dt.d, dt.m, dt.y);
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct date { What is the size of date Assume that unsigned int takes
int d : 5; 32 bit.
int m : 4; A. 8 B. 12
int y;
}; C. 24 D. Compiler error

int main()
{
printf("Size of date is %lu bytes\n",
sizeof(struct date));
struct date dt = { 31, 12, 2021 };
printf("Date is %d/%d/%d", dt.d, dt.m, dt.y);
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct date { What is the size of date Assume that unsigned int takes
int d : 5; 32 bit.
int m : 4; A. 8 B. 12
int y;
}; C. 24 D. Compiler error

int main()
{
printf("Size of date is %lu bytes\n",
sizeof(struct date));
struct date dt = { 31, 12, 2021 };
printf("Date is %d/%d/%d", dt.d, dt.m, dt.y);
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct test1 { What is the size of test1 in bytes Assume that unsigned
unsigned int x : 5; int takes 32 bit.
unsigned int y : 8; A. 4 B. 12
};
int main() C. 24 D. Compiler error
{
printf("Size of test1 is %lu bytes\n",
sizeof(struct test1));
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct test1 { What is the size of test1 in bytes Assume that unsigned
unsigned int x : 5; int takes 32 bit.
unsigned int y : 8; A. 4 B. 12
};
int main() C. 24 D. Compiler error
{
printf("Size of test1 is %lu bytes\n",
sizeof(struct test1));
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct test2 { What is the size of test2 in bytes Assume that unsigned
unsigned int x : 5; int takes 32 bit.
unsigned int : 0; A. 4 B. 8
unsigned int y : 8;
}; C. 12 D. Compiler error

int main()
{
printf("Size of test2 is %lu bytes\n",
sizeof(struct test2));
return 0;
}
Technical Training (Structure)
#include <stdio.h>
struct test2 { What is the size of test2 in bytes Assume that unsigned
unsigned int x : 5; int takes 32 bit.
unsigned int : 0; A. 4 B. 8
unsigned int y : 8;
}; C. 12 D. Compiler error

int main()
{
printf("Size of test2 is %lu bytes\n",
sizeof(struct test2));
return 0;
}

You might also like