Go Back   Computer Forums > Welcome To Computer Forums .org > Social Lounge | Off Topic
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 02-24-2006, 02:22 AM   #1
Fully Optimized
 
Paradox's Avatar
 
Join Date: Aug 2005
Posts: 2,913
Send a message via AIM to Paradox Send a message via MSN to Paradox Send a message via Yahoo to Paradox
Default Critical Thinking Problem (Lets see if any of you guys can figure it out)

You need to

Ok. I have to write a code that finds the Largest and smallest integer entered. I do this by checking if the number is greaterthan or less than the other numbers that were entered.. But you theres nothing to compare it to if it keeps changing everytime it loops, I need to make input = something different each time it loops or something then compare the results afterwards but you cant change it during the loop either...

This is pissing me off because if i wasnt so tired id be able to do this in 2 seconds, but im like having a brainfart or something. Like those times when theres a name, or a word or something and its like right at the tip of your tongue you just cant quite get it, only worse

This is what I have so far:

Code:
#include <iostream.h>

	int input, totalint, average, largest, smallest, difls, sum, devideby;

int main()
{
	cout << "Please enter in your integers one at a time. \n(Type 0 to quit)\n";

	do {
		cin >> input;
		totalint = totalint++; 
		sum = sum + input;
					    //If statement goes here

	} while (input !=0);
		devideby = totalint - 1;
		average = sum / devideby;
		cout << "Number of Integers entered: " << totalint - 1<< endl;
		cout << "Average of Combined Integers: " << average << endl;
		cout << "Largest Integer Entered: " << largest << endl;
		cout << "Smallest Integer Entered: " << smallest << endl;
		cout << "Difference Between Largest and Smallest integers: " << difls << endl;
		cout << "Sum of Combined Integers: " << sum << endl;
	return 0;
}
(Project Requirements:
Display number of integers entered
The average of all the integers
Largest integer entered
Smallest integer entered
Difference between largest and smallest integers
)

Ever if you dont get the code part you should be able to get the how to figure out largest and smallest integers (hopefully)
__________________

__________________
ROW ROW FIGHT THE POWAH

Xbox Live: Error Lord
Personal Email: HunterMRose[at]gmail.com
Aim: Error Lord
Paradox is offline   Reply With Quote
Old 02-24-2006, 03:19 AM   #2
Fully Optimized
 
Š88's Avatar
 
Join Date: May 2005
Posts: 4,775
Send a message via MSN to Š88
Default Re: Critical Thinking Problem (Lets see if any of you guys can figure it out)

You need to implement a dynamic array to store the values that are being entered so you can compare them. Or you can just use a regular array if you know how many numbers you are inputting for comparison before run-time. Let me know if you need more help.
__________________

__________________
Killing under the cloak of war is no different than murder

Kein Alkohol ist auch keine Lösung!
Š88 is offline   Reply With Quote
Old 02-24-2006, 05:26 AM   #3
Fully Optimized
 
UK31337's Avatar
 
Join Date: Feb 2005
Posts: 2,776
Default Re: Critical Thinking Problem (Lets see if any of you guys can figure it out)

I know how this could be done, but I'm in a lecture right now

I'll hack it together later for you.
__________________
Master of common sense. If you don't like it, stop reading.
UK31337 is offline   Reply With Quote
Old 02-24-2006, 04:45 PM   #4
Fully Optimized
 
Paradox's Avatar
 
Join Date: Aug 2005
Posts: 2,913
Send a message via AIM to Paradox Send a message via MSN to Paradox Send a message via Yahoo to Paradox
Default Re: Critical Thinking Problem (Lets see if any of you guys can figure it out)

Its alright, I took a break, came back, got the array running
__________________
ROW ROW FIGHT THE POWAH

Xbox Live: Error Lord
Personal Email: HunterMRose[at]gmail.com
Aim: Error Lord
Paradox is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 03:26 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0