C Programming – Basics of Structures

C Programming - Basics of Structures

Question 1
Which of the following are themselves a collection of different data types?
A
string
B
structures
C
char
D
All of the mentioned
Question 2
 User-defined data type can be derived by___________.
A
struct
B
enum
C
typedef
D
All of the mentioned
Question 3
Which operator connects the structure name to its member name?
A
-
B
<-
C
.
D
Both (b) and (c)
Question 4
 Which of the following cannot be a structure member?
A
Another structure
B
function
C
Array
D
None of the mentioned
Question 5
 Which of the following structure declaration will throw an error?
A
struct temp{}s; main(){}
B
struct temp{}; struct temp s; main(){}
C
struct temp s; struct temp{}; main(){}
D
None of the mentioned
Question 6
What is the output of this C code?
        #include 
        struct student
        {
        int no;
        char name[20];
        }
        void main()
        {
        struct student s;
        s.no = 8;
        printf("hello");
        }
A
Compile time error
B
Nothing
C
hello
D
Varies
Question 7
What is the output of this C code?
        #include 
        struct student
        {
        int no = 5;
        char name[20];
        };
        void main()
        {
        struct student s;
        s.no = 8;
        printf("hello");
        } 
A
Nothing
B
Compile time error
C
hello
D
Varies
Question 8
 What is the output of this C code?
    #include 
    struct student
    {
    int no;
    char name[20];
    };
    void main()
    {
    student s;
    s.no = 8;
    printf("hello");
    }
A
Nothing
B
hello
C
Compile time error
D
Varies
Question 9
. What is the output of this C code?
    #include 
    void main()
    {
    struct student
    {
    int no;
    char name[20];
    };
    struct student s;
    s.no = 8;
    printf("%d", s.no);
    }
A
Nothing
B
Compile time error
C
Junk
D
8
Question 10
Can the above code be compiled successfully?
    #include 
    struct p
    {
    int k;
    char c;
    float f;
    };
    int main()
    {
    struct p x = {.c = 97, .f = 3, .k = 1};
    printf("%f\n", x.f);
    }
A
Yes
B
No
C
Depends on the standard
D
Depends on the platform
Question 11
What is the output of this C code?
        #include 
        void main()
        {
        struct student
        {
        int no;
        char name[20];
        };
        struct student s;
        no = 8;
        printf("%d", no);
        }
A
Nothing
B
Compile time error
C
Junk
D
8
Question 12
Number of bytes in memory taken by the below structure is?
    #include 
    struct test
    {
    int k;
    char c;
    };
A
Multiple of integer size
B
integer size+character size
C
Depends on the platform
D
Multiple of word size
Question 13
What is the output of this C code?
    #include 
    struct
    {
    int k;
    char c;
    };
    int main()
    {
    struct p;
    p.k = 10;
    printf("%d\n", p.k);
    }
A
Compile time error
B
10
C
Undefined behaviour
D
Segmentation fault
Question 14
What is the output of this C code?
    #include 
    struct
    {
    int k;
    char c;
    } p;
    int p = 10;
    int main()
    {
    p.k = 10;
    printf("%d %d\n", p.k, p);
    }
A
Compile time error
B
10 10
C
Depends on the standard
D
Depends on the compiler
Question 15
What is the output of this C code?
    #include 
    struct p
    {
    int k;
    char c;
    };
    int p = 10;
    int main()
    {
    struct p x;
    x.k = 10;
    printf("%d %d\n", x.k, p);
    }
A
Compile time error
B
10 10
C
Depends on the standard
D
Depends on the compiler
Question 16
What is the output of this C code?
    #include 
    struct p
    {
    int k;
    char c;
    float f;
    };
    int p = 10;
    int main()
    {
    struct p x = {1, 97};
    printf("%f %d\n", x.f, p);
    }
A
Compile time error
B
0.000000 10
C
Somegarbage value 10
D
0 10
Question 17
What is the output of this C code(according to C99 standard)?
    #include 
    struct p
    {
    int k;
    char c;
    float f;
    };
    int main()
    {
    struct p x = {.c = 97, .f = 3, .k = 1};
    printf("%f\n", x.f);
    }
A
3.000000
B
Compile time error
C
Undefined behaviour
D
1.000000
Question 18
What is the output of this C code(according to C99 standard)?
    #include 
    struct p
    {
    int k;
    char c;
    float f;
    };
    int main()
    {
    struct p x = {.c = 97, .k = 1, 3};
    printf("%f \n", x.f);
    }
A
3.000000
B
0.000000
C
Compile time error
D
Undefined behaviour
Question 19
What is the output of this C code(according to C99 standard)?
    #include 
    struct p
    {
    int k;
    char c;
    float f;
    };
    int main()
    {
    struct p x = {.c = 97};
    printf("%f\n", x.f);
    }
A
0.000000
B
Somegarbagevalue
C
Compile time error
D
None of the mentioned

Check Your Answers:

  1. B
  2. D
  3. C
  4. B
  5. D
  6. A
  7. B
  8. C
  9. D
10. C
11. B
12. B
13. A
14. A
15. B
16. B
17. A 
18. B
19. A

SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment