Questions tagged [logic-error]
42 questions
1
vote
0 answers
Logical Issue in MongoDB Search Filter | NodeJS
I am working on a cab booking api. The issue i am facing on is a getAllBookings api which will be used by admin to get the history of all the bookings from booking database. Speaking of database, i shall share the database model for my booking model…

Faizan
- 11
- 2
1
vote
0 answers
In creating a "clear" button
So I'm trying to make a 'clear' button that is able to clear textfields. I've looked at tutorials and practically copied the code word for word, yet there's still errors. If someone could please provide some insight, that would be greatly…

Loki_A_Degenerate
- 11
- 3
1
vote
1 answer
Problem Implementing Conway's Game of Life
Conway's Game of Life : A cellular automata
Represented in an infinite two dimensional matrix of 'cells'
Each cell can be in two states, 'alive' or 'dead'
Each cell interacts with its horizontally, vertically, and diagonally adjacent…

Ioan
- 25
- 4
1
vote
2 answers
Taylor series expansion of cos(x) is not working
#include
#include
#define PI 3.1416
double fact(n){
double x = 1;
for(int i = 1 ; i <= n ; i++){
x = x*i;
}
return x;
}
int main(void) {
int deg,term,n=1,sign=1;
float radian,result=0;
printf("Enter the Angle (in…

Naveen
- 13
- 2
1
vote
2 answers
C Language: Triple nested while() loop that does not work correctly
I want to write a code in C language to output a list of triples matching the Pythagorean triple in a range of positive integers (a2 = b2 + c2 with a, b and c ∈ ℤ+) using only nested while () loops.
I wrote this:
//Programme to output possible…

Vynylyn
- 172
- 11
1
vote
2 answers
Please explain this Java loop logic error
I am expecting the below loop logic to bring cookies to 504 before printing 42. The program will run but nothing is returned.
public static void main(String[] args) {
int cookies = 500;
while(cookies % 12 != 0) {
if…

Lax
- 21
- 1
1
vote
1 answer
Why is my Circular Array Queue not adding the very last inputted value?
I'm having some difficulty with fully implementing my Circular Array Queue with Java. Specifically, my enqueue is failing to queue the very last value inputted in my queue. I've tested dequeuing and re-enqueuing values and it worked fine until I…

ihill
- 23
- 6
1
vote
1 answer
Logic Error in Chessboard Virus Simulation
The Chessboard virus problem is similar to Conway's "Game of Life". The rule is that any two squares with infected neighbours will become infected.
I have tried to implement the simulation in Python, but there is a logic error. I think what is…

Robin Andrews
- 3,514
- 11
- 43
- 111
1
vote
1 answer
For some reason, my loading "circle" will not working when I have it as a method or just normally in an if statement. Anyone know why?
Here is the code that I have for my Test program. I have all the code in order to avoid a runtime or syntax error but I don't know if this is a logic error
import java.util.Scanner;
public class Test {
static void Load() throws…

Dov Abrahim Kanner
- 11
- 1
1
vote
0 answers
Logic error when running simple Python Calculator
Yesterday I started to learn Python, and so far I'm enjoying the simplicity of it. Today, I tried creating a simple calculator that can add, subtract, multiply, divide, and mod. While it works perfectly fine, whenever the program asks the user if…

Bryan Chavez
- 11
- 1
1
vote
1 answer
virtual memory manager convert logical to phyiscal address useing TLB and page table
the goal of my program is to take a list of 1000 logical…

Bell
- 29
- 5
1
vote
1 answer
Logic error while trying to solve adventofcode day 4
This is on day four of advent of code part two...
I tried out the sample input they gave and it was correct and I used the input I have and comes out wrong every time
What I see 1
What I see 2
There is more below but its what happens after you solve…

Nboj
- 21
- 2
0
votes
1 answer
Calculate inverse kinematics of 2 DOF planar robot in python
I have a robot that is represented as a list of sequential joints and links:
class JointType(Enum):
REVOLUTE = 1
@dataclass
class Joint:
id: str
type: JointType
angle: float
@dataclass
class Link:
id: str
length:…

Blue7
- 1,750
- 4
- 31
- 55
0
votes
1 answer
Execution of 'You lost' loop in Hangman game despite winning the game on the last try
I have been trying to build a Hangman game, but I am facing a problem. The game runs fine, but every time I guess the word on my last chance, instead of the “You won!” block being executed, the “You lost! Try again” block gets executed. I have added…

Huzaifa
- 3
- 2
0
votes
1 answer
Logic error within my very simple Caesar cipher program
I'm trying to create a little project (I'm new to C#) where someone can input a key and a string to encrypt. However I have a logic error and it does not display. I have tried my best to explain each line best I could.
char[] alphabet =…