Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C99 Programming language Some languages provide a way to create a value of a str

ID: 3811423 • Letter: C

Question

C99 Programming language

Some languages provide a way to create a value of a structured type "on the fly, " without first storing it in a variable. In Ada, for example, an array or record value can be created by using an aggregate. In an Ada aggregate, either positional or named notation can be used, with mixing of the two allowed. (a) What is the name of this feature in C99? (b) For what types is this feature supported in C99? (c) Does C99 allow the use of positional notation? If so, give an example for each supported type. (d) Does C99 allow the use of named notation? If so, give an example for each supported type. (e) Does C99 allow the use of both positional and named notation? If so, give an example for each supported type.

Explanation / Answer

1)This feature is known as DESIGNATED INTIALIZERS

2)This feature is supported by arrays,structures and unions.

3)Yes,C99 supports aggregates with positional notations (mostly used for array elements).
For example:-

4)Yes,C99 supports aggregates with named notations (mostly used for indicating a member of a struct or union)
ex:-
  
        enum { member_one, member_two };
        const char *nm[] = {
                [member_two] = "member two",
                [member_one] = "member one",
        };


4)Yes,C99 supports aggregates with named and positional notations both mixed together.
Ex:-
   struct S2 a3[3] =
   {
   [2].y=6,[2].x=5,
   [1].y=4,[1].x=3,
   [0].y=2,[0].x=1
   };
   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote