473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Finding the lowest score

namcintosh
First of all, here is my program:

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <conio>
  3. using namespace std;
  4.  
  5. //Function prototype
  6. void getscore(int&, int&, int&, int&, int&);
  7. void findLowest (int, int, int, int, int, int);
  8. int main()
  9. {
  10.         int LO, score1, score2, score3, score4, score5;
  11.  
  12.         getscore (score1, score2, score3, score4, score5);
  13.         findLowest(LO, score1, score2, score3, score4, score5);
  14.  
  15.         getch();
  16.         return 0;
  17. }
  18.  
  19.  
  20.  
  21. void getscore (int &score1, int &score2, int &score3, int &score4, int &score5)
  22. {
  23.         cout << "Enter first score: ";
  24.         cin  >> score1;
  25.         cout << "Enter second score: ";
  26.         cin  >> score2;
  27.         cout << "Enter third score: ";
  28.         cin  >> score3;
  29.         cout << "Enter fourth score: ";
  30.         cin  >> score4;
  31.         cout << "Enter fifth score: ";
  32.         cin  >> score5;
  33. }
  34.  
  35. void findLowest(int LO, int score1, int score2, int score3, int score4, int score5)
  36. {
  37.  
  38.         LO = 1000;
  39.  
  40.         if (score1 < LO)
  41.         {
  42.             LO = score1;
  43.             cout << "The lowest score is" <<LO <<endl;
  44.         }
  45.  
  46.         else if (score2 < LO)
  47.         {
  48.             LO = score2;
  49.             cout << "The lowest score is" <<LO <<endl;
  50.         }
  51.         else if (score3 < LO)
  52.         {
  53.             LO = score3;
  54.             cout << "The lowest score is" <<LO <<endl;
  55.         }
  56.         else if (score4 < LO)
  57.         {
  58.             LO = score4;
  59.             cout << "The lowest score is" <<LO <<endl;
  60.         }
  61.         else if (score5 < LO)
  62.         {
  63.             LO = score5;
  64.             cout << "The lowest score is" <<LO <<endl;
  65.         }
  66. }
Okay, I got one part of the program to work right. The only problem is finding the lowest score.

I declared some if/else if statements and also assigned LO to a large number, such as 1000. Here's my output:

Expand|Select|Wrap|Line Numbers
  1. Enter first score: 100
  2. Enter second score: 75
  3. Enter third score: 55
  4. Enter fourth score: 100
  5. Enter fifth score: 85
  6. The lowest score is100
Do you see what I mean? It declares 100 as the lowest number. Why is it doing that?
Apr 20 '07
54 6552
Savage
1,764 Expert 1GB
Let's see,can u post ur new code here?


Savage
Apr 27 '07 #51
vfiles
3
hi there....

if i were allow to evaluate your code i would say you have made your program more complicated using your style..,but thats the way it is, everybody has its own way of solving problems..or maybe you are following intructions or something that you dont want to change your syntax flow..

what if lets make it a little bit shorter and more easy to analyze..
try this..
::code removed per FAQ::

i hope youll find what i really aiming of .
Apr 27 '07 #52
sicarie
4,677 Expert Mod 4TB
hi there....

if i were allow to evaluate your code i would say you have made your program more complicated using your style..,but thats the way it is, everybody has its own way of solving problems..or maybe you are following intructions or something that you dont want to change your syntax flow..

what if lets make it a little bit shorter and more easy to analyze..
try this..
::code removed per FAQ::

i hope youll find what i really aiming of .
vfiles-

You are correct, however it would be more beneficial to the OP if you posted an algorithm, and left the implementation to them, and then helped them refine it.
Apr 27 '07 #53
Savage
1,764 Expert 1GB
And we have already told that to the OP:

Functions like these are not modular.I would rather use arrays just in case i feel need for this function in future
Savage
Apr 27 '07 #54
And we have already told that to the OP:



Savage
It's been solved.

Thanks so much for all of your help you guys.
Apr 29 '07 #55

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Han | last post by:
Determining the pattern below has got my stumped. I have a page of HTML and need to find all occurrences of the following pattern: score=9999999999&amp; The number shown can be 5-10 characters...
4
by: Porthos | last post by:
Hi All, I'm trying to find the minimum value of a set of data (see below). I want to compare the lengths of these attribute values and display the lowest one. This would be simple if I could...
3
by: andreas.maurer1971 | last post by:
Hi all, since a few years I use the following statement to find duplicate entries in a table: SELECT t1.id, t2.id,... FROM table AS t1 INNER JOIN table AS t2 ON t1.field = t2.field WHERE...
6
by: Matt Chwastek | last post by:
Anyone who can help, I am curretnly attempting to write some code that will allow iteration using a vector<intfrom the highest possilbe degree of a combination of ones & zeros (111, 110, 101,...
2
sonic
by: sonic | last post by:
Does anyone know what I can do to this function to get it to drop the lowest value? Thanks for any insight. void sort(double* score, int size) { int startScan; int minIndex; double...
5
by: davenet | last post by:
Hi, I'm new to Python and working on a school assignment. I have setup a dictionary where the keys point to an object. Each object has two member variables. I need to find the smallest value...
1
by: Flanders | last post by:
I have developed a small arcade game with the help of a few VB books. A scoring system was implemented in the design of the game but I as hoping that some one would be able to instruct me on how...
2
by: marybrown | last post by:
i will write the complete problem i am facing. Here is the input file i am using. sxoght: #query hit score probability qstart qend qorientation tstart tend matches mismatches...
3
by: hamishmcgee | last post by:
Ok, so for a project at university I have to create a High Score table in C++ with Visual Studio. Just to let you know this is my first year at university and also my first time ever learning C++....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.