Jump to content
Sign in to follow this  
hacks_80

Clock Guna C++

Recommended Posts

sesapa tolong aku. aku try buat increment counter, so aku jadikan dia sebagai clock. ade sesapa yang ade idea untuk buat clock.

yg ni aku guna "for". yg bestnye minute ngan second baik punye jalan. tapi yg hour ni dok stay aje. tolong aku yek

#include <iostream>

using namespace std;

void main()

{

int hour,minute;

cout<<"hour :";

cin>>hour;

cout<<"minute :";

cin>>minute;

for(hour;hour<12;++hour)

for(minute;minute<60;++minute)

for(int sec=0;sec<60;++sec)

{

cout<<hour<<":"<<minute<<":"<<sec<<"\n";

cout<<endl;

}

}

Share this post


Link to post
Share on other sites

#include <iostream>
using namespace std;

int main()
{
	int hour,minute;
	cout<<"hour :";
	cin>>hour;
	//cout<<"minute :";
	//cin>>minute;
	for(hour;hour<12;++hour)
	for(minute=0;minute<60;++minute)
	for(int sec=0;sec<60;++sec)
  cout<<hour<<":"<<minute<<":"<<sec<<endl;
}

Share this post


Link to post
Share on other sites

aku rasa jawapan ko tak menepati soalan aku la.tapi takpe la, nice try.aku budjet nak buat dia tukar setempat aje tau.taknak dia count ke bawah.kalau boleh macam jam tangan digital tu.ade sesapa bleh tolong.plzzzz

Share this post


Link to post
Share on other sites
#include <iostream>
#include <windows.h> //for Sleep function

using namespace std;

int main()
{
	int hour = 0;
	int minute = 0;
	int sec = 0;

	cout<<"hour :";
	cin>>hour;
	cout<<"minute :";
	cin>>minute;
	do
	{
  system("cls");
  cout<<hour<<":"<<minute<<":"<<sec<<endl;
  Sleep(1000);
  sec++;
  if(sec >= 60)
  {
  	minute++;
  	sec = 0;
  }
  if(minute >= 60)
  {
  	hour++;
  	minute = 0;
  }
	}while(hour < 12);
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...