![]() Main (and only main) is allowed to implicitly return 0. Technically you don't need the return statement, but it's not a bad thing to keep it. You don't need the cmath header, you don't use anything from it. Simply follow the link and then click 'Run' button at the top to make the service to compile and run the program. You can immediately check this program out by visiting OnlineGDB. For example, std::cout << "What is your first number:\n" Example to create a simple calculator to add, subtract, multiply and divide using switch and break statement. It's a console calculator written in C for self-learning purposes. ![]() Similarly, so will your line with "CALCULATOR" and the question after it.Ĭout << string << char can be simplified to cout << string_with_char. The script interpreter of calc uses a C-like programming syntax. Missing newlines after printing your result/error, your asterisks will be on the same line. ![]() :13:10: error: no match for 'operator'} and 'double') Read your error messages, it's not pretty, but: Validate your input, what happens if I don't put in a number.ĭon't Repeat Yourself, you've got four cases that all end in the same line, that line could instead be one after the switch statement. "I'm stuck" doesn't tell anyone what might be wrong, or why you think it's wrong. First of all, it helps to both format your code with reddit markdown (four spaces before each line, or in the WYSIWYG editor there's a "code" button") and secondly state what the issue you're having is.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |