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

In C programming Write this 2 code: In C code ONLY Given the following function

ID: 3676793 • Letter: I

Question

In C programming Write this 2 code:

In C code ONLY Given the following function prototype void what_time_is_it(int total sec, int *hr, int *min, int *sec); Complete the definition of this function that converts number of secondsto time. Here, total_sec is a time represented as the number of seconds elapsed since midnight (00:00:00). hr,min, and sec are pointers to variables in which the function will store the equivalent time in hours (0-23), minutes (0-59), and seconds (0-59), respectively. Test your function in the main function. Complete the definition of the following function void find_two_largest (int a[], int n, int *largest, int *second largest); When passed an array a of length n, the function will search a for its largest element and second largest element, storing them in the two variables pointed to by largest and second_Jargest, respectively. Test your function in the main function.

Explanation / Answer

#include <stdio.h>
void what_time_is_it(int total_sec,int *h,int *min,int *sec){
       *sec=total_sec%60;
       *min=(total_sec/60)%60;
       *h=(total_sec/3600)%24;
      
}
int main()
{
       int time,h=0,min=0,sec=0;
       int largest,second_largest=0,a[50],n=0,i=0;
       printf("Enter total seconds elasped since midnight:00:00:00:");
       scanf("%d",&time);
       what_time_is_it(time,&h,&min,&sec);
       printf(" the time is now:%02d:%02d:%02d",h,min,sec);
       return 0;
}
output:
Enter total seconds elasped since midnight:00:00:00:3904
the time is now:01:05:04

#include <stdio.h>

void find_two_largest(int a[],int n,int *largest,int *second_largest){
   int i=0;int j=0,temp=0;
   for(i=0;i<n;i++){
       for(j=i+1;j<n;j++){
        if(a[i]<a[j]){
            temp=a[i];
           a[i]=a[j];
           a[j]=temp;
        }
        }
   }  
   *largest=a[0];
   *second_largest=a[1];
}
int main()
{
       printf("Enter total elements: ");
       scanf("%d",&n);

    printf(" Enter %d elements: ",n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
find_two_largest(a,n,&largest,&second_largest);
printf("Largest:%d Second:%d ",largest,second_largest);
       return 0;
}
output:
Enter total elements:6
Enter 6 elements:
15 14 15 48 75 62
Largest:75    Second:62

Enter 20 elements:
95 19 40 81 8 41 6 67 26 73 23 75 16 55 53 86 39 1 55 70
Largest:95    Second:86