Question

1. After the declaration: typedef struct { int part1; int part2; } Foo; Group of answer...

1.

After the declaration:

typedef struct { 
  int part1; 
  int part2;
} Foo;

Group of answer choices

Foo is a new data type which can be used to declare variables of this new type that holds two integers

Foo is a variable which holds a pointer to this new type that holds two integers

Foo is a variable which holds this new type that holds two integers

None of the above choices are correct

2.

After the declaration:

typedef struct { 
  int part1; 
  int part2;
} Foo;

Suppose you a variable named foo_ptr, which is pointer to a Foo (i.e. Foo * ). Which of the following is a proper way to access foo_ptr's part1 member?

Group of answer choices

foo_ptr->part1

*(foo_ptr.part1)

(*foo_ptr.part1)

None of the above

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Question 1:

The correct answer is A)

Explanation:

Typedef is used to define a new datatype according to our requirements.

In this case, a new datatype Foo is created which holds two integers part1, and part2.

We can use Foo datatype, just as we use other datatypes like int, char , float, etc.

Question 2:

The correct answer is A)

Explanation:

As foo_ptr is a pointer pointing to a variable of Foo type.

To access the fields part1 and part2 present in the Foo struct.

THe pointer should use -> operator.

foo_ptr->part1 , like this , the members can be accessed.

POINTERS use -> to access the fields directly while struct variables use dot(.) operator.

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

PLEASE COMMENT IF YOU NEED ANY HELP!

Add a comment
Know the answer?
Add Answer to:
1. After the declaration: typedef struct { int part1; int part2; } Foo; Group of answer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code in C language ADT: typedef struct{ int ID; float salary; int age; }Employee; ...

    code in C language ADT: typedef struct{ int ID; float salary; int age; }Employee; Specification: In this lab, five functions need to be implemented using the given ADT. 1. Employee* readRecord(FILE*) This function receives a FILE pointer created before. It reads a line from the provided csv file, and creates an Employee struct pointer with the information from that line then returns the pointer back to the calling function. Each line in the provided csv file contains the id, salary,...

  • Canvas → XC D Question 13 Given the code below: typedef struct p { char topic...

    Canvas → XC D Question 13 Given the code below: typedef struct p { char topic [20]; int nunWords; > page; typedef struct mag char name[20]; page pages [250); int numPages; } magazine; magazine m; How would you declare an array of 20 magazines? struct magazine[20] magazine[20] magazine myStack(20) None of the above struct m[191 Question 14 Given the code below: typedef struct char topic[20] Canvas & XC struct m[19] Question 14 Given the code below: typedef struct char topic[20];...

  • In this exercise, you will make a struct that contains x and y coordinates: struct point...

    In this exercise, you will make a struct that contains x and y coordinates: struct point {int x; int y;}; The object of this exercise is to make a singly linked list of these point structures. Add one more member called "next" to your point struct. It is a pointer to the next member of the linked list. The next member of the last point struct should point to NULL, which indicates the end of the list. Your program will...

  • I need help on this Systems review please! it's due by midnight monday. Question 1 Not...

    I need help on this Systems review please! it's due by midnight monday. Question 1 Not yet answered Points out of 1.00 Flag question Question text Using these declarations: int * numberPointers[3]; int * pointer; int number; Which of the following statements would generate a warning or error? Select one: a. number = pointer; b. *pointer = number; c. pointer = numberPointers; d. numberPointers[2] = &number; e. a., b., and d. f. a. and c. Question 2 Not yet answered...

  • 1) In the Quiz class, the foo method has the following API: public void foo( int...

    1) In the Quiz class, the foo method has the following API: public void foo( int x, String s) Which method call(s) would be correct assuming both a and y are integer values and assuming each statement is complete? a. Quiz q = new Quiz(); a = q.foo( y, “Maybe?” ); b. Quiz q = new Quiz(); q.foo( 1, “Hmmm!” ); c. Quiz q = new Quiz(); Quiz.foo( y, “You think” ); d. Both b and c 2) In the...

  • Define a type which comprises a struct called "Maxima". In this struct contains two int values...

    Define a type which comprises a struct called "Maxima". In this struct contains two int values a and b. The purpose of this struct is to store the largest two int values among a set of integers. The value a is the largest number and the value b is the second largest number. In order to accomplish this task, you need to write the following functions: allzero( struct pointer ): This function sets a and b values in a given...

  • PART1 Answer the following question in a Word document named as SP2019LAB7 PART1 YourlastName.doc...

    what's the solution for the c++ project? PART1 Answer the following question in a Word document named as SP2019LAB7 PART1 YourlastName.docx Question1: What is the output of the following program? #include <iostream> using namespace std; int main() int count; int alpha(51: alpha[0] -4; for (count 1; count <5; count++) alpha[count] = 4 * count + 1 alpha(count 1] alpha[counk] -8; LAB7 cout << List elements: "; for (count = 0; count < 5; count++) cout <s alphalcount]<<"" cout<s endl; return...

  • C++ pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point...

    C++ pointers and linked lists 1. Declare an integer pointer variable intPointer. Initialize it to point to an int variable named someInt. Assign the value 451 to someInt and output (cout) the variable someInt and output (cout) the value pointed to by intPointer. Write an assignment statement that indirectly stores 900 into the value pointed to by intPointer. Output (cout) the value pointed to by intPointer and output (cout) the variable someInt, 2. Declare a pointer variable charArrPointer and initialize...

  • Multiple Choice Multiple Choice Section 2.1 - 2.2 Introduction to Classes Here is the start of...

    Multiple Choice Multiple Choice Section 2.1 - 2.2 Introduction to Classes Here is the start of a class declaration: class foo { public: void x(foo f); void y(const foo f); void z(foo f) const; ... Which of the three member functions can alter the PRIVATE member variables of the foo object that activates the function? A. Only x can alter the private member variables of the object that activates the function. B. Only y can alter the private member variables...

  • Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p;...

    Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p; int i; int k; i = 42; k = i; p = &i; After these statements, which of the following statements will change the value of i to 75? A. k = 75; B. *k = 75; C. p = 75; D. *p = 75; E. Two or more of the answers will change i to 75. Consider the following statements: int i =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT