Using if and else help?

closed account (z09TURfi)
How can I attempt where if the user puts an invalid value he/she will be prompted with a negative warning repeatedly until he/she puts the associated number requested which is above 1000? I am trying to do a number countdown. It just stays stuck on the screen as soon as a value is entered.

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

string Polyhedron = " *\n * *\n * *\n * *\n * *\n * *\n * *\n * *\n * *\n * *\n * *\n * *\n * *\n * *\n * * * * * * * * * * * * * * *";
string LiNE = "_______________________________________________________________________________";


int main(void)
{
printf("\t \"Polyhedron\"\n"); cout<<endl; //Polyhedron = Pyramid
std::cout<<Polyhedron<<std::endl; //This is the Pyramid Drawing wannabe!

cout<<LiNE<<endl;

int N; //N stands for 'Number';

cout<<"Enter a number above 1000: ";
cin>>N;

if (N >= 1000)
{
cout<<N<<endl; --N;
}
else if (N <= 1000 )
{
cout << "Low number please try again!" << endl;
}
while (N !=0);

system("Pause");
return EXIT_SUCCESS;
}
Last edited on
closed account (DSLq5Di1)
http://www.cplusplus.com/doc/tutorial/control/#while
For the board archaeologists amongst us, the OP began:

Using if and else help?
How can I attempt where if the user puts an invalid value he/she will be prompted with a negative wa...


I just love it when people delete their posts. It undermines the whole point.
OP, you won't make any friends on here by deleting your posts. Necessary reading:
http://cplusplus.com/articles/oGLN8vqX/
closed account (z09TURfi)
I'm not on here to make friends... i'm on here to learn c++, friends or not doesn't matter to me. Why would you care if I deleted my post anyways, whats it to you ;/ hopefully deleting my post did not hurt your feelings?
I'm not on here to make friends... i'm on here to learn c++, friends or not doesn't matter to me


You have to put 2 and 2 together. If people here don't like you, then they won't be willing to answer your questions, which means you won't learn anything.

Make friends = learn stuff
Make enemies = learn nothing.

Why would you care if I deleted my post anyways, whats it to you ;/


Answers posted on the forum are meant to help more people than just the person who asked them. By leaving the question on the board, you keep the possibility of other people finding the thread and learning from it.

I can't tell you how many times I've had a problem and found an answer by googling the question and finding an old thread on some random forum where somebody asked the same question. It happens all the time. If everyone deleted their thread, finding solutions that way would be impossible.

It's also disrespectful to the people who took the time to answer.

It also sucks for you because it prevents the possibility of someone else chiming in and adding to (or correcting) the provided solution.


So basically... it's a jerk move. Don't do it.
You have to put 2 and 2 together. If people here don't like you, then they won't be willing to answer your questions, which means you won't learn anything.


&&

So basically... it's a jerk move. Don't do it.


Indeed...

whats it to you ;/ hopefully deleting my post did not hurt your feelings?


My feelings are definitely hurt ;)

Perhaps it doesn't matter to you, but the only reason I come on to these forums is to help potential programmers get better, and to better myself. However if it's filled with jerks and unhappy people, there's no reason to come here =] So just be nice, and you'll get lots of help. That is why you're here right?
hopefully deleting my post did not hurt your feelings?

Impossible, I'm afraid. I read too many YouTube comments to get hurt feelings online anymore. Be careful though. As you can see, we have some members like ultifinitus who are rather more sensitive (@ulti =P)

However,
myself wrote:
you won't make any friends on here by deleting your posts

What the others have explained is correct - I just exercised a little tact and left you to infer the rest ;)

In summary: happy posting, but please, please don't delete your posts. I'll say no more as it's all in Albatross' article (to which I did link above).

-Xander
Last edited on
The Internet is just a giant remembering machine and you're not playing by the rules, OP.
closed account (z09TURfi)
Lol, you guys really take this "post deletion" very serious. I am not here to dispute with any of you, and I knew the reasons for why it's not good to delete posts. I just had asked a simple question using if and else, and since I have figured it out after watching a couple youtube flixes I just decided to amputate my post. But anyways... i'll respect the "no deleting post rule" and proceed learning cplusplus. In addition, I am still a beginner with some basic knowledge so it would be really interesting to speak with a professional cplusplus programmer. I'm not working on any projects or attending a community college. I just decided to learn c++ for my own interest.
Although I wish I was learning this as a child... i'd probably be swell with it by now. I'm only 21 -.-
I recommend you start with the tutorial on this site, if you haven't already. Then you can try some programs and use your experiences to direct you in any questions you might want to ask.

Then get a good book, because you'll struggle to find an online tutorial which beats that. And check out some cool libraries such as Boost, SFML and Qt!

Lol, you guys really take this "post deletion" very serious

Yeah ;) Though with my last post I was really just amusing myself - sorry for that...
Topic archived. No new replies allowed.