I am unsure where I am going wrong in my code. I am trying to create a program that allows the user to enter a number, the program ends when the user enters 0. The program also needs to show the sum of the numbers entered. When I compile and run the code, it shows the endless "Please ebter a number (0 to terminate):".
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
I am unsure where I am going wrong in my code. I am trying to create a
Hey! Hope you are doing good!
The basic Problem of the code that you have provided is that you have somehow told the computer to repeat "Please Enter a Number (0 to terminate)" until the value does not change to 0, since it is written inside the loop.
The very first time when we input a number other than 0 then the value of the variable "value" changes and it is not zero, so the computer gets stuck in an infinite loop until the program is terminated forcefully.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images