beginners program

R

robertnielsen

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?
 
H

Howard

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
 
R

rossum

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
 
R

robertnielsen

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;
}
 
O

osmium

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()" ?
 
K

Karl Heinz Buchegger

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?
 
B

Boboo

(e-mail address removed) 写é“:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top