0% found this document useful (0 votes)
7 views

Using System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Using System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

namespace teptep

class Program

public static void Main(string[] args)

Console.WriteLine("Enter a number 0f ");

int second = Convert.ToInt32(Console.ReadLine());

int hours = second / 3600;

int minutes = (second % 3600)/60;

int remainingsecond= (second % 3600) % 60;

Console.WriteLine("Cnverted time:"+hours+"
minutes:"+minutes+ " seconds:"+remainingsecond);

Console.ReadKey(true);

}
using System;

namespace teptep

class Program

public static void Main(string[] args)

int totalSeconds = 3660;

int hours = totalSeconds / 3600;

int minutes = (totalSeconds % 3600) / 60;

int seconds = totalSeconds % 60;

Console.WriteLine("Hours: " + hours);

Console.WriteLine("Minutes: " + minutes);

Console.WriteLine("Seconds: " + seconds);

}
Explanation:

using System;: This line allows the program to use types and methods from the System
namespace, which contains fundamental types and base class libraries.

namespace teptep: This line declares a namespace called teptep. Namespaces are used to
organize code and avoid naming conflicts.

class Program: This line declares a class named Program. Classes are the fundamental building
blocks of C# programs.

public static void Main(string[] args): This line declares the entry point of the program, the Main
method. It is a static method (meaning it belongs to the class itself rather than an instance of the
class), returns void (meaning it doesn't return any value), and accepts an array of strings as input
arguments (args). Inside Main, the program logic is implemented.

int totalSeconds = 3660;: This line declares an integer variable named totalSeconds and
initializes it with the value 3660. This variable represents the total number of seconds.

int hours = totalSeconds / 3600;: This line calculates the number of hours in totalSeconds by
dividing it by 3600 (the number of seconds in an hour). The result is stored in the variable hours.

int minutes = (totalSeconds % 3600) / 60;: This line calculates the number of minutes by finding
the remainder when totalSeconds is divided by 3600 (to remove the hours), then divides that
remainder by 60 (the number of seconds in a minute). The result is stored in the variable
minutes.

int seconds = totalSeconds % 60;: This line calculates the remaining seconds after extracting the
hours and minutes. It uses the modulus operator (%) to find the remainder when totalSeconds is
divided by 60 (the number of seconds in a minute). The result is stored in the variable seconds.

Console.WriteLine(...): These lines output the calculated values to the console, along with
descriptive labels.

You might also like