Search Header Logo

C-structures , bitfields,union and File Handling

Authored by Shaik Imam

Professional Development

University

Used 3+ times

C-structures , bitfields,union and File Handling
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Can the following C code be compiled successfully?

    #include <stdio.h>

    struct p

    {

        int k;

        char c;

        float f;

    };

    int main()

    {

        struct p x = {.c = 97, .f = 3, .k = 1};

        printf("%f\n", x.f);

    }

Depends on the standard

No

Depends on the platform

Yes

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following C code?

    #include <stdio.h>

    struct student

    {

        int no;

        char name[20];

    };

    void main()

    {

        student s;

        s.no = 8;

        printf("%d",s.no);

    }

Nothing

8

Compile time error

Junk

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What would be the size of the following union declaration? (Assuming size of double = 8, size of int = 4, size of char = 1)

    #include <stdio.h>

    union uTemp

    {

        double a;

        int b[10];

        char c;

    }u;

4

8

40

80

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following C code

#include <stdio.h>

union temp

{

int a;

float b;

char c;

};

int main()

{

union temp s = {1,2.5,’A’};

printf("%c",s.c);

return 0;

}

'1'

Compilation error

'A'

Nothing

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following C code? (Assuming size of char = 1, int = 4, double = 8)

    #include <stdio.h>

    union utemp

    {

        int a;

        double b;

        char c;

    }u;

    int main()

    {

        u.c = 'A';

        u.a = 1;

        printf("%zu", sizeof(u));

    }

8

4

1

13

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of this program? 

#include <stdio.h>

int main()

{

typedef struct tag {

char str[10];

int a;

} tag;

tag h1, h2 = { "IHelp", 10 };

h1 = h2;

h1.str[1] = 'h';

printf("%s, %d", h1.str, h1.a);

return 0;

}

Error

IHelp 10

Ihelp 10

No Error ,No output

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of this program?

#include <stdio.h>

int main()

{

union test {

int i;

int j;

};

union test var = 10;

printf("%d, %d\n", var.i, var.j);

}

10,10

garbage values

Nothing

Compilation Error

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?