| | |
error checking help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Solved Threads: 0
I need to error check a user input and it must be a value between 0 and 13 whole numbers only. it will be stored in a int variable using the cin function. I dont remember how to do this since i have not taken a c++ course in 3 years. This assignment is using top down progamming, not object oriented programming.
perhaps this will help jog your memory
Last edited by Duki; Sep 11th, 2007 at 2:03 pm.
It is practically impossible to teach good programming style to students that have had prior exposure to Basic; as potential programmers they are mentally mutilated beyond hope of regeneration.
-Edsger Dijkstra
-Edsger Dijkstra
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Solved Threads: 0
I looked at the tutoral and have not seen anything about error checking i think I have the basic concept of c++ I have completed the top down course at my school. I am now enrolled in opject oriented programing class. My first assigment is a review from my last class and my notes on error checking are terrible. that is my fault but i dont have anything to look at to see how to set this one up. any help you can give would be greatly appriciated. I am not sure what this text box means by surround code could you briefly explain this to me as well. this is the first time i have ever posted a thread. thankyou soo much.
when/if you paste any of your code in a reply you need to do it like this
[code.]
\\code goes here
[/code.]
of course, you want to take out the '.' after the word code which makes your reply look like this:
etc.
As for the error checking, consider this. If you wanted to check that 'x' is less than 10 but greater than 0, you could use the following construct:
So now, what else could you check with the if/else statements and how?
Does this help any?
[code.]
\\code goes here
[/code.]
of course, you want to take out the '.' after the word code which makes your reply look like this:
C++ Syntax (Toggle Plain Text)
#include <iostream> ... return 0 ;
As for the error checking, consider this. If you wanted to check that 'x' is less than 10 but greater than 0, you could use the following construct:
C++ Syntax (Toggle Plain Text)
if ( x > 0 && x < 10 ) cout << "Excellent!" << endl ; else { cout << "Invalid Input!! -- Exiting program!!" << endl ; exit ( 1 ) ; }
So now, what else could you check with the if/else statements and how?
Does this help any?
It is practically impossible to teach good programming style to students that have had prior exposure to Basic; as potential programmers they are mentally mutilated beyond hope of regeneration.
-Edsger Dijkstra
-Edsger Dijkstra
![]() |
Similar Threads
- Custom error checking (C#)
- error checking (Java)
- User Form error checking (PHP)
- Help with 1.pointers and 2.error checking (C++)
- Error Checking for user input (Java)
- error checking of user input (C++)
- Basic Error Checking (C++)
- How to Perform Disk Error Checking in Windows XP (Windows tips 'n' tweaks)
Other Threads in the C++ Forum
- Previous Thread: Deciding return type of a function at runtime
- Next Thread: C++ BGI Graphic Help!
Views: 639 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






