Homework Help Question & Answers

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
Report
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!

Know the answer?
Add Answer to:
1. After the declaration: typedef struct { int part1; int part2; } Foo; Group of answer...
Your Answer: Your Name: What's your source?
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
  • 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];...

  • 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,...

  • 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...

  • 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...

  • COMPUTER SCIENCE (URGENT)

    DO WHAT YOU CAN DO FOR NOW , YOU CAN OTHER QUESTIONS LATER . IT'S DUE IN 2 WEEKS FROM TOMORROW WORTH 100POINT.PSS: IF YOU DON'T KNOW HOW TO DO IT PLEASE LEAVE IT BLANKPSS:IF YOU ARE MR "IT'S ME" AGAIN PLEASE LET ME KNOW"1.A function that is called or summoned into action by its reference in another function is a ____.A) function prototypeB) called functionC) calling functionD) function declarator2.The items enclosed within the parentheses in a function call statement...

  • Array

    1) Declare an array named a of 10 elements of type int and initialize the elements (starting with the first) to the values 10, 20, ..., 100, respectively.2) Declare an array named taxRates of 5 elements of type double and initialize the elements (starting with the first) to the values 0.10, 0.15, 0.21, 0.28, 0.31,respectively.3) Write a statement to declare and initialize an array of int named denominations that contains exactly six elements.Your declaration statement should initialize the elements of...

  • c++

    22. A pointer may be initialized witha. the address of an existing objectb. the value of an integer variablec. the value of a floating point variabled. all of thesee. None of these23. What does the following statement do?double *num2;a. Declares a double variable named num2.b. Declares and initializes an pointer variable named num2.c. Initializes a variable named *num2.d. Declares a pointer variable named num2.e. None of these24. When the less than ( < ) operator is used between two pointer...

  • C++ 1. A?B?C?D? which one is correct 2. 3A, 3B #include<iostream> using namespace std; void swap0(int*...

    C++ 1. A?B?C?D? which one is correct 2. 3A, 3B #include<iostream> using namespace std; void swap0(int* ptri, int* ptr2) { int *temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap1(int ptri, int ptr2){ int temp; temp = ptri; ptr1 = ptr2; ptr2 = temp; portion void swap2(int *&ptri, int *&ptr2){ int* temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap3(int &ptri, int &ptr2) { int temp; temp = ptr1; ptr1 = ptr2; ptr2 =...

  • Fill the blank in each of the following using the terms at the bottom. IT. When...

    Fill the blank in each of the following using the terms at the bottom. IT. When an array is created, a value in the array is called a(n) 12. f and ) must always be used with an if) statement: True or False 13. Theoperator is used to check if two values are equal. 14. A command can only be used in a loop statement. 15. Acommand can be used in both a loop and switch statement. 16. In the...

  • QUESTION 1 Using the following declarations and a member of the Array class, int [ ]...

    QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...

Free Homework 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.