Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Short coding questions c++ Write the declaration for a struct called pythType that holds 3 integers named num1, num2, and num3. Based on a), write
Short coding questions c++
- Write the declaration for a struct called pythType that holds 3 integers named num1, num2, and num3.
- Based on a), write the declaration for an array called pythNumber that holds 12 elements and each elements data type is pythType.
- How much memory is allocated to the variable pythNumber?
- Write the statement to print out the value of the field of num2 of the 6th element of pythNumber.
- If you declare a variable as follow:
pythType *p=new pythType;
How would you assign 24 to num3 field in the new created node which is pointed by p?
- Based on a) and b), write the function prototype, header and body for a function called checkPyth. It takes pythNumber as a parameter and checks to see if there exists an element which is a Pythagorean triple. Three numbers are a Pythagorean triple if they can be the lengths of the sides of a right triangle. That is, if the numbers are a, b and c then the numbers are a Pythagorean tripe if the following holds:
a2 + b2 = c2.
This function returns true if there exists an element which is a Pythagorean triple, and false otherwise.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started