Computer Science, asked by hedashreyas2, 11 months ago

Create a structure time with data members as hrs, min , sec.accept the value from user and display it . Also perform addition of two time variables and display the result . If sec goes beyond the 60 , carry it to min . Add a method to convert the given statement Into sec


In C program

Answers

Answered by hisuchi1981
1

Answer:

I am sorry but I do not know C programming.....I am only acquainted to BlueJ....

Answered by jyotirajranjan76
0

Answer:

import java.util.Scanner;

class Time

{

int hour; int min; int sec;

void get_time()

{

Scanner in = new Scanner(System.in); System.out.print("Enter hours: "); hour = in.nextInt();

System.out.print("Enter minutes: "); min = in.nextInt();

System.out.print("Enter seconds: "); sec = in.nextInt();

}

void show_time()

{

System.out.println(hour + ":" + min + ":" + sec);

}

public static void main(String args[])

{

Time obj = new Time();

obj.get_time();

obj.show_time();

}

}

OR,IN C LANGUAGE

include < stdio.h >   

#include < conio.h > void main()  

{  

    int sec, hr = 0, min;  

    clrscr();  

    printf("\n Enter seconds:");  

    scanf("%d", & sec);  

    min = sec / 60;  

    sec = sec % 60;  

    if (min >= 60)  

    {  

        hr = min / 60;  

        min = min % 60;  

    }  

    if (hr != 0)  

    {  

        printf("\n No of hours:%d", hr);  

        printf("\n No of minutes:%d", min);  

        printf("\n No of seconds:%d", sec);  

    } else if (hr == 0)  

    {  

        printf("\n No of Minutes:%d", hr);  

        printf("\n No of seconds:%d", min);  

    }  

    getch();  

}  

I HOPE IT WILL HELPFULL!!!.

Similar questions