You are using a version without Ads of this website. Please, consider donating:

### another stupid question :S

hey everybody ...as im a starter i tried to create some single scripts first... so i decided to make a program which gets what ever number the user wants and then it calculates the min.
it compiles without any error but its really weird that it calculates the max instead... + idk why there is something wrong with the loop.
could some body help me? :S
 ``123456789101112131415161718192021222324252627282930313233343536`` ``````#include #include int main() { int a; char c; int i; int min; i=1; c='y'; while(c=='y') { cout<<"Please enter number"<>a; cout<<"Do you wanna continue?(y,n)"; c=getche(); if(c=='y') { cin>>a; if(a>min) { min==a; } } if(c=='n') { cout<<"here is the min:"<
If you are trying to calculate the minimum you will want to do
` if(a < min ` not ` if (a > min) `

Also at line 23 you will want to use = not ==.
` min = a; `

= is used for directly assigning values
== is used to compare 2 variables.

It is also odd that is does a check for the minimum when the user enters in n.
Last edited on
i edited it a lil bit... it works fine when i press y ... but the count system( please press the number "i") doesnt work :( also when i press n it doesnt count the min :S
 ``12345678910111213141516171819202122232425262728293031323334353637`` ``````#include #include int main() { int a; char c; char d; int i; int min; i=1; c='y'; while(c=='y') { cout<<"Please enter number"<>a; cout<<"Do you wanna continue?(y,n)\n"; c=getch(); if(d=='y') { cin>>a; if(a>min) { min==a; } } if(d=='n') { cout<<"here is the min:"<min) { min=a; } i++; } } }``````
Last edited on
can anybody help? :S
Here's my take on it.
 ``123456789101112131415161718192021222324252627282930313233`` ``````#include using namespace std; int main() { char c; int a,b,min; c='y'; cout<<"Please enter a number: "; cin>>a; min=a; while(c=='y') { cout<<"\nPlease enter another number: "; cin>>a; if(c=='y') { if(a>c; } cout<<"Here is the minimum: "<
I see you're using a very old compiler, from before 1998. This is a bit silly. Get a modern, free compiler.
@ocasio101 : thx :)
@moschops : well this is what we use in class (as begginers in pawn) any modern compiler you suggest? which is kinda near turbo c++? :)
Quit using Turbo C++. It's a very old compiler and if you are studying from a modern book your programs won't compile to be correct even if they are. Use Visual C++ Express (it's free) from Microsoft or use G++ via MinGW or Cygwin.
Yeah, your two main choices are Visual C++ (blurgh) or Code::Blocks (awesomesauce)
Topic archived. No new replies allowed.

You are using a version without Ads of this website. Please, consider donating: