nothing weird in my compiler; just got a simple textbox saying hello world. used visual c++ 2010.
That was cool. But you know what, it would be super cool if u explain the code too, because i have a doubt that even you can understand that.
[QUOTE=WaltP;1419149]And your question about this poor code is... what?[/QUOTE]
hi...why is the code poor? i mean, i didn't even know we could shutdown the pc using c.
can u please tell me a (better) way? Thanks
[QUOTE=flasp;1409886]ty very much...[/QUOTE]
Please mark the threads solved when you're finished with the problem.
The program converts number of hours into days.
after this, try to code that inputs number of minutes and converts in x days y hours & z minutes.
then u can easily work with seconds.
using namespace std ;
int days, hours ;
int long inputHours ;
cout << "Enter Number Of Hours: " ;
cin >> inputHours ;
days = inputHours / 24 ; //Quotient(Days)
hours = inputHours % 24 ; //Remainder(Hours)
cout << days << "Days and " << hours << "Hours" << endl ;
[QUOTE]Lol ok guys, I try to fix it tonight .[/QUOTE]
[QUOTE=flasp;1409547]Done that, and doesnt come up with correct result.. I hope someone can help me with making the code?[/QUOTE]
I have the code but won't post it unless you show what you tried.
Come on, just give it a shot.
[QUOTE=xikkub;1408726]Following standard programming conventions, it's undesirable to use global variables where locals will do. Use less output and text formatting. Remove unnecessary cout lines and simplify your code before adding final touches. If you simplify the code and learn how to [U]pass data to a function[/U], you can make your work much easier.
Also, Jason, declaring a character array of 10 is NOT a good idea in this case since the day name length can vary. If anything, I'd use a dynamic character array.[/QUOTE]
I just wanted to demonstrate use of array, size needn't be fixed. I was giving an idea how cout can be reduced.
also, thanks for the fact about the global variables, i'll keep that in mind.
Try generalising the program using global variables. instead of using so many cout statements printing the same thing, use one cout and the variables(which will have different values acc to time and day). use a func to calc the values of variables.
day = "Monday";
day = "tuesday"
day = "wednesday"
cout << "The Call Was Made On " << day << endl ;[/CODE]