473,404 Members | 2,137 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,404 software developers and data experts.

Error in Simple Program

In the program below, 1 and 1000 are not included as a valid number. Why is it that when I enter 1 or 1000, the program does not say "enter a valid number"? It just ends the program. Help is appreciated. thanks

Expand|Select|Wrap|Line Numbers
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int iX;
  7.  
  8.     do {
  9.         cout << "Enter a Number between 1 and 1000." << endl;
  10.         cin >> iX; 
  11.  
  12.     if ( iX < 1 || iX > 1000) {        
  13.         cout << "Enter Valid number. Try Again." << endl;
  14.         }
  15.     }while (1 > iX || iX > 1000); 
  16.  
  17.     return 0; 
  18.  
  19. }
Apr 18 '10 #1

✓ answered by Banfa

If the program is not doing what you require the error is in lines 12 and 15. Run the program logic yourself with the values 1 and 1000 (and 0, 2, 999, 1001) and you will understand what the problem is and be able to correct your conditionals to achieve what you desire.

2 1273
Banfa
9,065 Expert Mod 8TB
If the program is not doing what you require the error is in lines 12 and 15. Run the program logic yourself with the values 1 and 1000 (and 0, 2, 999, 1001) and you will understand what the problem is and be able to correct your conditionals to achieve what you desire.
Apr 18 '10 #2
I over looked that one...It needs an = sign on both the lines u mentioned.Thanks a lot Banfa
Apr 19 '10 #3

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

Similar topics

9
by: Dario | last post by:
This is a technical C++ post regarding the Microsoft runtime error R6025 Pure Virtual Function Call that sometime occurs in programs compiled with Microsoft Visual C++ 6.0. Please consider the...
3
by: Victor | last post by:
I'm trying to run this java program, but somehow the program always quit w/o giving any error msg at all. it happenned inside the first case statements. Strangely, after printing happen2, it just...
14
by: tasheeta | last post by:
In my simple program I am getting this error..please help I am trying to find integers where 65537i + 3551j = 1 error: cannot convert `__complex__ int' to `long int' in assignment ...
10
by: ale.of.ginger | last post by:
Greetings! I am trying to make a multiplayer (no AI, 2 person) game of tic tac toe in Python. So far it has been pretty simple. My only concern is with the win checking to see if a person has...
8
by: Cybert | last post by:
I just installed Microsoft Visual Basic .NET and wrote a very simple program that references a .tlb file called "Wilbur". The first time I ran the program below everything worked fine. But...
4
by: Maileen | last post by:
Hi, I did a VB.NET application but i don't want to deliver the .NET framework to each of my users. Instead of this, i just would like to do a big try and catch and in case of an error is...
4
by: junaidnaseer | last post by:
Hi ! I am facing a problem that I have defined a function which when called in the same file generates an error as follows; " visual c error C2371 redefinition basic types see...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
0
by: RCM | last post by:
I am really eager to quit the Microsoft world and get into LAMP. For the immediate future I can't do the Apache part, so I am at least trying to get PHP up and running under IIS to learn it. I...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.