What if the input inputted is negative




















You should just write a loop like this. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to terminate input as a list when a negative integer is entered? Asked 7 years, 4 months ago. Active 7 years, 4 months ago. Viewed 3k times. How to terminate input in a list when a negative integer is entered? Is there a way to replace more than one item in a list or a string?

Improve this question. Dan S. Calculate the Power of a Number. Join our newsletter for the latest updates. This is required. C Program to Check Whether a Number is Positive or Negative In this example, you will learn to check whether a number entered by the user is negative or positive.

Check Positive or Negative Using if Check Positive or Negative Using Nested if Share on:. Did you find this article helpful? Sorry about that.

How can we improve it? Leave this field blank. Related Examples. In the above programs, the condition is always true. Hence, the loop body will run for infinite times. However, while and do Course Index Explore Programiz. Popular Examples Create a simple calculator.

Check prime number. Print the Fibonacci sequence. Check if a number is palindrome or not. Program to multiply matrix. Reference Materials iostream. Join our newsletter for the latest updates. This is required. In computer programming, loops are used to repeat a block of code.



0コメント

  • 1000 / 1000