Computer Science, asked by ashamishra170pci228, 1 year ago

Write a program to input seconds and dislay time broken as hours minutes and seconds?

Answers

Answered by shantanurauthan
2

This program is written in C language

It first calc secs into mins.

And then it checks if the user has entered secs which constitute to more than 60 mins or less than 60 mins.

If the total minutes calculated are above 60 then the hours conversion logic code is executed.

#include<stdio.h>

int main(){

int n,hr,min,sec;

printf("Enter seconds:");

scanf("%d",&n);

if(n>3600){

min = n/60;

sec = n%60;

hr = min/60;

min = min%60;

printf("Converted format %d hour %d mins %d secs",hr,min,sec);

}

else{

min = n/60;

sec = n%60;

printf("Converted format %d mins %d secs",min,sec);

}

}


ashamishra170pci228: sry in java i want
shantanurauthan: :( you should have mentioned that..anyway put up your question again i ll try to code it in java.
ashamishra170pci228: oky
ashamishra170pci228: dude ONE MORE PROGRAM. WRITE A PROGRAM TO ROUND OFF TWO DECIMAL PLACES IN JAVA EX - INPUT - 12.367. OUTPUT- 12.37
Similar questions