PDA

View Full Version : [Source]Example of using a Void function



[EclipsE]AgentGOD
10-22-2005, 02:00 PM
#include <iostream> //Preprocessor directive
using namespace std;

void CheckPerformance(double score); //Function Declaration
//Main function heading
int main()
{
double score3d; //Double variable, score3d
cout << "FEAR Performance Estimate v1.0" << endl;
cout << "By [Spyder]-005/AgentGOD" << endl << endl;
cout << "Enter your 3DMark05 score: ";
cin >> score3d; //Stops program execution, and allows user to store score in score3d
cout << "Estimating performance levels..." << endl;
CheckPerformance(score3d); //Calls CheckPerformance function
system("PAUSE"); //Stops program execution to let user see results
return 0;
}
//Function: CheckPerformance
//Description: Inputs the score the user enters, and displays the result on the screen
//Input: Score
//Output: None
void CheckPerformance(double score)
{
cout << "------------------------" << endl;
if(score <= 3000)
{
cout << "Level: Snail" << endl << "You may not run this game with a decent gameplay level at all, performance NOT guarenteed" << endl;
}
if(score <= 4799)
{
if(score >= 3000)
{
cout << "Level: Low/Mediocre" << endl << "You will be able to run the game at Low/Medium settings" << endl;
}
}
if(score >= 4800)
{
if(score < 7000)
{
cout << "Level: High" << endl << "You will be able to run the game at High settings" << endl;
}
}
if(score >= 7000)
{
cout << "Level: Very High" << endl << "You will be able to run the game at High/Maximum settings" << endl;
}
cout << "------------------------" << endl;
}

I have added comments to tell you what each function does, good luck to you all.

To compile: Copy and paste the code into a C++ project. (It works with Dev-C++, CodeWarrior, and Microsoft Visual C++)

gamepin126
10-22-2005, 02:01 PM
You're hella fat.

[EclipsE]AgentGOD
10-22-2005, 02:01 PM
I know ;)

gamepin126
10-22-2005, 02:02 PM
Alright, just making sure you knew that. It'd be like the worst thing in the world, to think you're skinny all of your life. Then someone calls you fat, and you're like "WTF I'M HELLA SKINNY!" and they're like "Nuh uh.". Then you look in the mirror, and you're like "Holy Bejesus, I'm hella fat." Then you're like, "Oh well. I should probably live up to my fatness.". Next week you die, because you had a heart attack, and cholesterol is through the roof, and your heart can't pump so much blood, through so much fat.

RIP: AgentGOD, he died with a twinkie in his mouth.

[EclipsE]AgentGOD
10-22-2005, 02:04 PM
Of course ;)

llafnwod
10-22-2005, 02:05 PM
Stop posting threads, Agent. Now. You cannot go on making threads for every new infantile C++ concept you come across that would take any competant learner all of 3 seconds to comprehend. Keep your idiotic discoveries contained to one thread, at least.

[EclipsE]AgentGOD
10-22-2005, 02:07 PM
What discoveries ;) I just got the feeling to share a little knowledge with some pals.

gamepin126
10-22-2005, 02:09 PM
He's giving back to the community. If he took anymore from it, his computer would explode. He's just getting rid of excess...

Uniquely_Defined
10-22-2005, 03:36 PM
Are you learning C++? Or are you just craving attention?

kds
10-22-2005, 03:43 PM
AgentGOD']What discoveries ;) I just got the feeling to share a little knowledge with some pals.
You don't have pals here. As llafnwod said, anyone with the slightest bit og intelligence can figure this out in about 5 minutes.

Belphegor
10-22-2005, 03:59 PM
Ive never touched a C++ tut, or book, and I understand the basics of that code snippet. Although, Zynastor's showed me some things, and lets just say, my balls dropped lower. :(

indulgence
10-22-2005, 05:16 PM
Why do you have to post about how to use a void function - its just a function that doesn't return a value... That was pretty ****ing simple, eh? And I didn't even need a snippet

SubZero
10-22-2005, 07:04 PM
Well said, indy. Btw, where have you been?

Aberrant
10-23-2005, 01:19 PM
Cool guess I should post my age calculation program that i did on my second day of learning C++ so I can be uber 1337 too.

K? Pŕo?ćtiόnŹ
10-23-2005, 03:11 PM
To be uber 1337 all the functions have to be void and all on one line.

Aberrant
10-23-2005, 05:31 PM
Hmmmm that might be a little usless to do an age calculation program that is supposed to return your age if it returns void...

Will have to look into it, sure agent will have figured it out so I guess I should ask him.

K? Pŕo?ćtiόnŹ
10-23-2005, 06:50 PM
Hmmmm that might be a little usless to do an age calculation program that is supposed to return your age if it returns void...

Will have to look into it, sure agent will have figured it out so I guess I should ask him.
global variables =D.

Zynastor
10-24-2005, 01:16 AM
Another usless thread by AgentGod, posting his newly learnt C++ skill "using a void function". What's next, How to use a function that returns an integer?

Sinz
10-24-2005, 12:15 PM
probally gonna get introuble for pointing out a mistake in a post about intelligence:lol:

You don't have pals here. As llafnwod said, anyone with the slightest bit of intelligence can figure this out in about 5 minutes.

kds
10-24-2005, 12:18 PM
oh geez, a minor spelling mistake. my finger must have accidentally hit the g key instead of the f key, because they are right next to each other. that makes me so much less intelligent. somebody get the cross and nails, i'm going to be crucified!

K? Pŕo?ćtiόnŹ
10-24-2005, 12:21 PM
oh geez, a minor spelling mistake. my finger must have accidentally hit the g key instead of the f key, because they are right next to each other. that makes me so much less intelligent. somebody get the cross and nails, i'm going to be crucified!
Ill get the whip and thorn crown.

tk
10-25-2005, 06:45 AM
Dan']Ill get the whip and thorn crown.
Ill get the cheez Whiz!