Home Forums C Programming Question about my program code

Viewing 0 reply threads
  • Author
    Posts
    • #2023
      happyherlean
      Participant

      Hi!
      I’m a beginner in C++ The program below inputs sevaral positive numbers with decimal points, analyzes these numbers, and outputs the result. The program works fine. But I wanted to make sure that a user puts only positive numbers or -1 to end repetition loop. So, I created couple of functions that would check the numbers, return them in case if they are positive or equal -1. In case they are negative, the program would output warning message and ask to enter the number again. It also work fine, but if I enter negative number and than enter positive number, the program saves negatives number, although I return the value from the function. Can anyone please explain me where my error is. Thanks!

      P.S. I know that it’s possible to use template functions when you have a function that does the same operations, but with different types of variables. Can I use this concept with my problem when I have similar functions, but different names of variables? If yes, can anyone please show me how? Thanks!

Viewing 0 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.