Needed help with something
#1
Posted 21 December 2003 - 10:07 PM
Too cute! | Server Status: If you can read this, it's up |Well, when it comes to writing an expository essay about counter-insurgent tactics, I'm of the old school. First you tell them how you're going to kill them. Then you kill them. Then you tell them how you just killed them.
#2
Posted 22 December 2003 - 03:50 PM
Too cute! | Server Status: If you can read this, it's up |Well, when it comes to writing an expository essay about counter-insurgent tactics, I'm of the old school. First you tell them how you're going to kill them. Then you kill them. Then you tell them how you just killed them.
#3
Posted 22 December 2003 - 07:12 PM
#pragma hdrstop
#include <iostream.h>
#include <conio.h>
int main()
{
double HoursPerDay;
double MoneyPerDay;
double Answer;
cout << "How many hours do you work per day?";
cin >> HoursPerDay;
cout << "How many money do you make for the hours?";
cin >> MoneyPerDay;
Answer = HoursPerDay * MoneyPerDay;
if(HoursPerDay > 24)
cout << "You Must Be Jocking!!!";
else
cout << "You make" << Answer << "Money per day";
getch();
}
Using void is like saying "please shutdown" to XP when it's running on a 486DX2.
#4
Posted 22 December 2003 - 09:54 PM
#pragma hdrstop #include <iostream.h> #include <conio.h> int main() { double HoursPerDay; double MoneyPerDay; double Answer; /// double blah; cout << "How many hours do you work per day?"; cin >> HoursPerDay; if(HoursPerDay > 24) cout << "You Must Be Jocking!!!"; else cout << "How many money do you make for the hours?"; cin >> MoneyPerDay; Answer = HoursPerDay * MoneyPerDay; cout << "You make" << ' ' << Answer << ' ' << "$ per day"; cout <<"\n"; getch(); }
#6
Posted 22 December 2003 - 10:52 PM
#7
Posted 23 December 2003 - 08:52 AM
No errors.
When i compile my program and run it, everything is fine.It works ok, but at the end it simply exits.No matter do i put getch() or void main() with return 0 - it will close after i have entered the second number.
I have attached the program.See that it exitst.
Attached Files
#8
Posted 24 December 2003 - 01:00 AM
if(HoursPerDay > 24) cout << "You Must Be Jocking!!!"; else { cout << "How many money do you make for the hours?"; cin >> MoneyPerDay; }
im not sure as to what options dev c++ uses when it runs the command prompt, wether to keep it open after program is done executing. however, int main() and return 0; should work.
#9
Posted 24 December 2003 - 04:31 AM
Too cute! | Server Status: If you can read this, it's up |Well, when it comes to writing an expository essay about counter-insurgent tactics, I'm of the old school. First you tell them how you're going to kill them. Then you kill them. Then you tell them how you just killed them.
#10
Posted 25 December 2003 - 08:24 AM
Don't use void main() and return 0. That defeats the purpose of using void. I'm not really sure if I can do a good job of explaining why theres different words there to a beginner but i'll give it a shot.No matter do i put getch() or void main() with return 0
int is short for integer as you probably know by now. When you declare int main() you are declaring the main function (you can call other functions, but main is the function that will automatically run). The int part comes because you can make a function output a variable. So I could have double main() or whatever. But in most cases you don't really want or need main to output something so in C you can use void main(). Which basically says its a void or null value as in there is not and will never be any data outputted from that function. So therefore it does not make sense to return 0 to a void function because you are not returning anything. return basically says what value to give the function if it can output a value. I hope that is accurate as I'm a bit rusty with c++.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users