+ 1
How to check if the user's input doesn't contain parentheses?
I am coding a program that should calculate various values of a geometric shape or form. So far I've completed the code for squares and rectangles only on the 2nd dimension and I had a problem with the surface becoming negative for example if the user inputs a positive number between parentheses http://cpp.sh/6y5zh I suggest you check function aPositive() at the bottom since it's the one containing the a variable which should be positive and a float.I want to make a loop that checks if the input contains:()
8 Respuestas
+ 1
I do this example, you can detect the pharenteses looking for his ASCII value, for example, into a for loop. But you can choice other ways to resolve it.
https://code.sololearn.com/csCoGVFAJY4Z/?ref=app
+ 1
Can you copy your code to Code Playground? then link the code with the question, hopefully that way people can easily view your code and offer suggestions. :)
0
so if I want to run an error if the user inputs parentheses do I do while (check>=1) {
cout << "error"; cin >> example;
}
?
0
You must detect the number into (). Not only the pharenteses, its correct?
0
oh yeah I either want to detect the number inside and keep the code running or give the user an error and not detect the number
0
and why did you make the array length constant if it's the user's entry
0
That code is only a example to detect a pharenteses. About the error, you are the programmer, you decide it