How do I print error statements when using if and else commands in C++?

  • Context: C/C++ 
  • Thread starter Thread starter ineedhelpnow
  • Start date Start date
  • Tags Tags
    Error Printing
Click For Summary

Discussion Overview

The discussion centers around how to print error statements in C++ when using if and else commands. It explores the methods of displaying error messages to users, particularly in the context of validating conditions such as the formation of a triangle.

Discussion Character

  • Technical explanation, Conceptual clarification, Homework-related

Main Points Raised

  • One participant asks for clarification on what specific error message the original poster intends to print.
  • Another participant suggests a specific error message related to triangle validation, mentioning the use of the printf function.
  • Some participants note the importance of indicating the nature of the error to the end-user for better understanding.
  • There are repeated acknowledgments from participants about the simplicity of outputting an error statement.

Areas of Agreement / Disagreement

Participants generally agree on the need to print error statements, but there is no consensus on the specific content or method of displaying these messages.

Contextual Notes

There are missing details regarding the specific conditions under which the error messages should be printed and the context of the overall program structure.

ineedhelpnow
Messages
649
Reaction score
0
im using the if and else commands in c++ and for the else i want the program to print an error statement. how do i do this?
 
Technology news on Phys.org
Can you elaborate more ? What error message are trying to type ? I think you are already familiar with printf function.
 
You could simply output something like:

"The three given sides do not form a valid triangle."

I'm not certain how you are expected to display output, but I seem to recall using the [m]printf()[/m] function.
 
yeah i realized that all i had to do was output an error statement
 
ineedhelpnow said:
yeah i realized that all i had to do was output an error statement

Typically, as the coder, you want to indicate the nature of the error to the end-user so that the user has some idea what went wrong. :D
 

Similar threads

Replies
1
Views
6K
Replies
7
Views
2K
Replies
14
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K