Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Observe the usual guidelines regarding the initial comment section, indenting, a

ID: 3806452 • Letter: O

Question

Observe the usual guidelines regarding the initial comment section, indenting, and so on. In addition, when functions are required, place function definitions following main. Before each function use comments to explain what the function does. Do not use global variables. In function main prompt the user for a time in seconds. Call a user defined function to calculate the equivalent time in hours, minutes, and seconds. Parameters should be the time in total seconds and pointers to the hours, minutes, and seconds. Print the equivalent in hours, minutes, and seconds in function main. Test with a value of 36884 seconds. Output should look something like this: "5000 seconds can be broken into l hour 23 minutes and 20 seconds" In function main declare coordinates for two points (x1, yl, x2, y2) and slope m and y-intercept b. Call a function get2points to read in the two sets of coordinates. Return the values to function main, pass by address. Call a second function slopelntercept to calculate the values of slope m and intercept b for the form y = mx + b. Function slopelntercept has six parameters, the four coordinate values and pointers to the slope and y-intercept. Call a function displayEquation to print the final form of the equation. Enclose the call statements in a while or do.... while loop so that additional coordinates can be converted to the slope intercept format if desired. Test with coordinate pairs: (4, 3) and (-2, 1) (1, 1) and (5, 17.8)

Explanation / Answer

#include<stdio.h> //including header files

main()

{

Long sec,hr,min,t;

Printf(“ enter time in seconds:”); //promping a message to the user to enter the seconds

Scanf(“%d”,&sec); //reading those seconds enter by the user

hr= sec/3600; //getting the hours value by deviding the secs with 3600

t=sec%3600; // with modular operation the stored value is stored into a variable called "t"

min=t/60; // getting the minutes values by deviding "t" value with 60

sec=t%60; // with modular operation from "t" we getting seconds value

Printf(“ time is %ldhour %ld minutes %ld seconds”,hr,min,sec); // finally we are printing the seconds into required format

Getch();

}

Sample output:

Enter time in seconds:5000

Time is 1hour 23minutes and 20 seconds