473,382 Members | 1,421 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,382 software developers and data experts.

beginners program

i am new to c++ and am practicing programs. i am trying to write a
program that a user enters a sequence of numbers and the program will
pick out the lowest and highest numbers in the bunch. i will enter -99
to exit the loop. any one help?

Jul 23 '05 #1
6 1204

<ro***********@cfu.net> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
i am new to c++ and am practicing programs. i am trying to write a
program that a user enters a sequence of numbers and the program will
pick out the lowest and highest numbers in the bunch. i will enter -99
to exit the loop. any one help?


Not without some effort on your part. If you don't know how to do this,
then you need to do some reading. If there's just a specific part you're
not sure about, take a stab at it, post what you have, and explain what part
you're having problems with. But we're not just going to do your homework
for you.

-Howard
Jul 23 '05 #2
On 30 Mar 2005 13:48:30 -0800, ro***********@cfu.net wrote:
i am new to c++ and am practicing programs. i am trying to write a
program that a user enters a sequence of numbers and the program will
pick out the lowest and highest numbers in the bunch. i will enter -99
to exit the loop. any one help?


Start very simple. Write a program where the user enters one number.
Print out that number and then finish. Test your program and check
that it works. If you have a problem post it here and we will be able
to help.

Next write a program where the user enters two numbers. Print them
both out. Test it before proceeding. Post it here if you get stuck.

Then a program where the user enters three numbers. Print the highest
and the lowest. Test again. Programmers do a lot of testing.

Finally write the program you want. At your stage it is probably
better for you to take very small steps, don't try to go straight to
the final program.

rossum
The ultimate truth is that there is no ultimate truth
Jul 23 '05 #3
well here is what i have so far. having some probs with the variables
though.
as far as doing my homework for me, i am just dinking with this stuff.
if you dont wanna help then just move on with out any comments.


//test program
//user inputted numbers
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int number1;
cout<<"please enter an integer: "<<endl;
cin>>number1>>endl;
cout<<number1<<endl;
system ("pause");
return 0;
}

Jul 23 '05 #4
<ro***********@cfu.net> wrote:
well here is what i have so far. having some probs with the variables
though.
as far as doing my homework for me, i am just dinking with this stuff.
if you dont wanna help then just move on with out any comments.


//test program
//user inputted numbers
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int number1;
cout<<"please enter an integer: "<<endl;
cin>>number1>>endl;
cout<<number1<<endl;
system ("pause");
return 0;
}


You don't ask a question. But where do you expect the compiler to find this
thing you call "system()" ?
Jul 23 '05 #5
ro***********@cfu.net wrote:

well here is what i have so far. having some probs with the variables
though.
as far as doing my homework for me, i am just dinking with this stuff.
if you dont wanna help then just move on with out any comments.

//test program
//user inputted numbers
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int number1;
cout<<"please enter an integer: "<<endl;
cin>>number1>>endl;
You can't read into 'endl'.
'endl' is not a variable.
cout<<number1<<endl;

system ("pause");
return 0;
}


After fixing that: Can you procedd to the next step.
Read in a loop until -99 is entered?

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #6
ro***********@cfu.net 写道:
well here is what i have so far. having some probs with the variables
though.
as far as doing my homework for me, i am just dinking with this stuff.
if you dont wanna help then just move on with out any comments.


//test program
//user inputted numbers
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int number1;
cout<<"please enter an integer: "<<endl;
cin>>number1>>endl;
cout<<number1<<endl;
system ("pause");
return 0;
}


I will assume that you are working with dev-C++,

here's my code,hope it can help a little,btw,i have no idea why you want
to finish the loop with -99..isn't -99 an integer? :P

code:

#include <iostream>

using std::cin; using std::cout; using std::endl;
int main()
{
int maxlen;
int minlen;
int num;
int counter = 1;

cout << "Please enter No.1: ";
cin >> num;
maxlen = num;
minlen = num;

while(num != -99)
{
counter++;
cout << "Please enter No." << counter << ": ";
cin >> num;
if((maxlen < num) && (num != -99))
maxlen = num;
if((minlen > num) && (num != -99))
minlen = num;
}

cout << "so the biggest one is: " << maxlen << endl;
cout << "and the smallest one is: " << minlen << endl;

system("pause");
return 0;

}

think this code is not that clear...need someone to fix it :)

cheers.

Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: tjland | last post by:
This is my first version of this program, im kinda new to python and i was wondering if someone could help me with this. Their are some errors that i just cant find, and i want some advice on how...
7
by: Will | last post by:
Pardon two post in a row to the newsgroup but I want to try and expedite this, if you guys don't mind helping out... I running Windows XP Pro and wanted to download Python and any additional...
38
by: BORT | last post by:
Please forgive me if this is TOO newbie-ish. I am toying with the idea of teaching my ten year old a little about programming. I started my search with something like "best FREE programming...
7
by: tada991 | last post by:
Hello Everyone, I just purchased Visual Studio .Net Architect 2003 and want to know what's a good book for begginers to start with. I know nothing about programming whatsoever, but I do have a...
6
by: William Foster | last post by:
Does anyone know of a good online tutorial for C# focused on beginners. I have been to many great sites like csharpfriends, csharp-corner etc looking for good tutorials and have had no luck. Any...
18
by: John Salerno | last post by:
Hi all. I was hoping some of you could recommend a book or two that would help me get started with the basics of C#. I have a slight knowledge of programming, but basically I want to start out like...
9
by: iceman4022 | last post by:
Here is a program I have to write for an assignment. I cannot get it to exit when I click cancel and for some reason I get an error when you enter 3 as your option. I am sure it is a beginners...
19
by: yltkhuu | last post by:
1. How does having a widely adopted C++ standard help game programmers? 2. What are the advantages ans disadvantages of employing the "using" directive? 3. Why might you define a new name for an...
5
by: mlewis | last post by:
Hello and thanks in advance for any help. I'm just starting out on PHP and read the very useful exercise at...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.