Hi this is for my computer engineering class and its a practice exam from last s
ID: 3807142 • Letter: H
Question
Hi this is for my computer engineering class and its a practice exam from last semester we're supposed to use to study, but he didn't add the solutions. Please Help! If you could please explain how you acquired your answer that would be great!
Exam III (100 pts) November 17, 2016 CPE 112 Fall 2016 25. (12 pts) Finish the program below by adding a void function as specified below. Add only a function prototype, function cal statement and function definition to the following program. Do not add any variable declarations. The name of the void function is Initstruct The function has one parameter of the struct DataType Time. The function is to initialize the structure parameter with a time of 12:00:00 AM.(form is HH:MM:SS) The information stored in the parameter must be available in main0 after the function call. #include kiostream> using namespace std; struct Time format of the time is HH: MM: SS designator where HH is for hours MM for minutes and SS for seconds int hour; int minute; int second; string designator for AM or PM Place the function prototype below this line int main() Time appt appt is a structure variable of data type Time Place the function call below this line return 0; Place the function definition below this lineExplanation / Answer
Please use the below c++ Program to fullfill your task, Please note that the values to initialize the time is hardcoded in the program as it was not specified in the question.
Program:
#include<iostream>
using namespace std;
struct Time
{
//format of the time is HH:MM:SS designator
//Where HH is for hours, MM is for minutes and SS for seconds
int hour;
int minute;
int second;
string designator; // for AM or PM
};
//Function Prototype
void InItStruct(Time*);
int main()
{
Time appt; //appt is a structure variable of data type time
//Function Call
InItStruct(&appt);
//Printing the initialize time
std::cout<<"Initialize Time in (HH:MM:SS designator) format: ";
std::cout<<appt.hour<<':'<<appt.minute<<':'<<appt.second<<' '<<appt.designator;
return 0;
}
//Function Defination
void InItStruct(Time *time)
{
//Hardcoding the parameter values that is going to assign
time->hour = 02;
time->minute = 30;
time->second = 59;
time->designator = "AM";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.