1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alisha [4.7K]
4 years ago
6

Define a function setheight, with int parameters feetval and inchesval, that returns a struct of type heightftin. the function s

hould assign heightftin's data member feet with feetval and inches with inchesval.
Computers and Technology
1 answer:
devlian [24]4 years ago
4 0

It is given that the feetVal and inchesVal are parameters of the SetHeight() function. Since the return type of the function is structute, so we need to define a structure.

After that, we need to create a structure variable within the function definition. Now, assign the feet and inches with the feetVal and inchesVal respectively. Finally return the structure variable.

Further explanation:

#include<stdio.h>

//define the structure

typedef struct HeightFtIn_struct {

int feet;

int inches;

} HeightFtIn;

//define the function

HeightFtIn SetHeight(int feetVal, int inchesVal)

{

HeightFtIn Htft; //creating a structure variable of type HeightFtIn

//assign the value of feetVal

Htft.feet = feetVal;  

Htft.inches = inchesVal; //assigning the value of inchesval

//return the structure variable

return Htft;

}

int main(void) {

HeightFtIn studentHeight;

int feet;

 int inches;

printf("Enter the values of feet and the inches: ");

scanf("%d %d", &feet, &inches);

studentHeight = SetHeight(feet, inches);

printf("The student's height is %d feet and %d inches.\n", studentHeight.feet, studentHeight.inches);

return 0;

}

Output:

Enter the values of feet and the inches: 5 9

The student's height is 5 feet and 9 inches.

Learn more:

1. A company that allows you to license software monthly to use online is an example of ? brainly.com/question/10410011  

2. How does coding work on computers?  brainly.com/question/2257971 

Answer details:

Grade: College Engineering

Subject: Computer Science

Chapter: C  Programming

Keyword:

C++, input, output, programming, statements,  loops, if, else, statements, firstname, lastname, base class, derive class, vector, print

You might be interested in
The local Driver's License Office has asked you to write
Y_Kistochka [10]

One of the most popular object-oriented programming languages is C++. Stroustrup created C++ by adding object-oriented features to the C programming language.

<h3>How do you write a program in C++?</h3>
  • Some people believe that the open-source C++ IDE Dev C++ is one of the finest. However, it may be used exclusively on Windows and macOS. It contains capabilities like profiling, integrated debugging, syntax highlighting, code completion, tool managers, and GCC-based compilers.
  • Many people believe that C++, an object-oriented programming (OOP) language, is the finest language for developing complex applications. The C language is a superset of C++.

#include <iostream>

#include <string>

#include <iomanip>

#include <cctype>

using namespace std;

class TestGrader

{

private:

string answer[20];

public:

void setKey(string[]);

void grade(string[]);

};

/*********************************************************************/

void TestGrader::setKey(string correct[])

{

for (int x = 0; x < 20; x++)

{

 answer[x] = correct[x];

}

}

void TestGrader::grade(string test[])

{

int right = 0;

int wrong = 0;

int count = 0;

for (int x = 0; x < 20; x++)

{

 if (test[x] == answer[x])

 {

  right += 1;

  count += 1;

 }

 else if (test[x] != answer[x])

 {

  wrong += 1;

 }

}

if (count >= 15)

{

 cout << "Congratulations you have passed the driver's license exam" << endl;

}

else

{

 cout << "You failed the driver's license exam" << endl;

}

cout << "You got a total of " << right << " right answers and a total of " << wrong << " wrong answers in the test" << endl;

cout << "You got questions ";

for (int x = 0; x < 20; x++)

{

 if (test[x] != answer[x])

 {

  cout << x + 1 << " ";

 }

}

cout << "wrong" << endl;

}

int main()

{

string answers[20] = { "B", "D", "A", "A", "C", "A", "B", "A", "C", "D", "B", "C", "D", "A", "D", "C", "C", "B", "D", "A"};

TestGrader exam;

exam.setKey(answers);

string yourTest[20];

int choice;

do

{

 for (int x = 0; x < 20; x++)

 {

  cout << "Enter the answer for question " << x + 1 << ": ";

  cin >> yourTest[x];

  while (yourTest[x] > "D"  || yourTest[x] < "A")

  {

   cout << "Please enter from A-D: ";

   cin >> yourTest[x];

  }

 }

 exam.grade(yourTest);

 cout << endl << "Enter -1 to quit, else enter any number to retake the exam: ";

 cin >> choice;

} while (choice != -1);

return 0;

}

To learn more about C++ refer,

brainly.com/question/15411348

#SPJ4

6 0
1 year ago
Which of the following players is on offence
Bumek [7]

Answer:

A baseball player trying to steal second base.

Explanation:

From a test I took, im hoping the answer choices were the same as yours tho.

7 0
3 years ago
In what type of attack does the attacker have the ciphertext of several messages that were encrypted with the same encryption al
Alexus [3.1K]
In ciphertext-only.

EXPLANATION: it is an attack model for cryptanalysis where the attacker is assumed to have access only to a set of ciphertexts. The attack is completely successful if the corresponding plaintexts can be extracted or, even better, the key.
3 0
3 years ago
13. You're emailing your grandparents. Which of the following is the best example of digital etiquette?
lorasvet [3.4K]
D. spelling out words and avoiding slang
6 0
2 years ago
Read 2 more answers
2
Elza [17]

A is the correct answer.

Hope this helps you!

3 0
4 years ago
Read 2 more answers
Other questions:
  • so im thinking about building my own pc for a decent price can anyone point me to a website where i can buy the parts and name t
    13·2 answers
  • Professor Zak allows students to drop the four lowest scores on the ten 100 point quizzes she gives during the semester. Design
    13·1 answer
  • : What is the difference between the Audio Mixer and the<br> Audio Meters Panel?
    7·2 answers
  • Question 1 :The most common business firewall technique is to use a firewall server in conjunction with:This task contains the r
    11·1 answer
  • How is a composite key implemented in a relational database model?
    11·1 answer
  • g Define several forms of metadata that can be useful to an investigation. How are valuable to an investigator
    10·1 answer
  • A _______ read inputs the first data item from a file. It typically appears immediately before the loop that processes the data
    5·1 answer
  • When using a small mic that attaches to your interview subject, where should you place that mic and why?
    5·1 answer
  • MCQ: Which of the following network is confined to a relatively small area?
    5·2 answers
  • What report indicates where users start or exit the conversion funnel?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!