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

c program nano (Structures) Consider the following program char firstName [100]

ID: 3832031 • Letter: C

Question

c program

nano

(Structures) Consider the following program char firstName [100] "Allen", lastName[100]; Struct {char *firstName char *lastName; int age;} p1, p2; p1.first Name = first Name; p1. last Name = lastName; p1.age = 0; p2 = p1; strcpy (p2.firstName, "Brain"); What is the string in p1.firstName after the execution of the code above? (Union) Consider union {char c; int i;} u; u.c = 'A'; Draw a memory picture for variable u. The size of each of your memory unit must be one byte. You should indicate clearly the member names of u in your picture. Give an example of defining a variable of enumeration type.

Explanation / Answer

1) Ans: Brain

Because; we are pointing p2 to p1: p2 = p1

So,from that point p1 and p2 pointing to same memory

2)

u ----->|A| <-- 10001 (lets say address)   

Size of memory unit is 2 byte(size of int)

3)


Enumeration (or enum) is a user defined data type in C. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain.

enum State {Working = 1, Failed = 0};
enum State {Working = 1, Failed = 0, Freezed = 0};

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