338 Answered Questions for the topic logic



Math logic question

Natalie has $68. If she doubles the number of her $5, she will have $103. How many $5 bills does Natalie have originally?


How to calculate scores?

This question is more related to logic than any programming language. If the question is not apt for the forum please do let me know and I will delete this. I have to write a logic to calculate... more
Logic Xor


Pass two integers as one integer?

I have two integers that I need to pass through one integer and then get the values of two integers back. I am thinking of using Logic Operators (AND, OR, XOR, etc) .


Jane can play the piano but not the flute while Jeremy plays the violin and the flute .Shelly plays the violin but not the piano and Josephine plays the flute but not the violin. If each child

Jane can play the piano but not the flute while Jeremy plays the violin and the flute .Shelly plays the violin but not the piano and Josephine plays the flute but not the violin. If each child... more
Logic Math C# Uint64


UInt64 and "The operation overflows at compile time in checked mode" - CS0220?

This feels like a stupid question, but I can't seem to see the answer. I have an UInt64, which is supposed to have a max value of UInt64.MaxValue 18446744073709551615 However, when I try to... more


Split down a number in seconds to days, hours, minutes, and seconds?

I've heard that it's possible to accomplish this using the modulus `%` operator present in most programming languages. The real question is, how? I'm unfamiliar with how modulus works, so I've had... more
Logic Truth Table


Write the following compound statement in symbolic form. This is not an apple an apple if​ it's not a fruit fruit.

Let p and q represent the following simple statements.​p: This is an applean apple.​q: This is a fruitfruit.


XOR of three values?

What is the simplest way to do a three-way exclusive OR? In other words, I have three values, and I want a statement that evaluates to true IFF only *one* of the three values is true. So far,... more

C# logic order and compiler behavior?

In C#, (and feel free to answer for other languages), what order does the runtime evaluate a logic statement? Example: DataTable myDt = new DataTable(); if (myDt != null &&... more


VBA If <any of these> = <value>?

I'm fairly new to VBA, and I can't find an easy way to test if any of the specified variables equal a specified value. The below seems to work, but is there an easier way to do it? If variable1 =... more


What' s the difference between <= and := in VHDL?

Currently, I am learning some FPGA design techniques using VHDL, my problem is whether we can use := and <= interchangeably in VHDL or not, though I've seen the use of := in constants... more


Force all && to be executed?

Consider the following variadic function template <typename Type, typename... Types> bool f(Type& arg, Types&... args) { return f(arg) && f(args...); } template... more
Logic Math Hint


determine whether point lies inside triangle?

The program needs to read the values of three coordinates - P1(x1,y1) - P2(x2,y2) - P3(x3,y3) as well as another coordinate P(x,y) and determine whether this point is inside a triangle... more

Logical fallacy detection and/or identification with natural-language-processing?

Is there a package or methodology in existence for the detection of flawed logical arguments in text? I was hoping for something that would work for text that is not written in an academic... more
Logic Algorithm


What's the approach to solving this kind of logic problem?

What would be the approach to a kind of problem that sounds like this: A says B lies B says C lies D says B lies C says B lies E says A and D lie How many lie and how many tell the truth? I... more


What is the Objective-C way of getting a nullable bool?

How should I go about getting a bool value that I can assign true, false and nil to in Objective-C? What is the Objective-C way of doing this? Much like C#'s Nullable<bool>. I'm looking to... more

P implies Q, how to read in english?

how to read P implies Q in classical logic? example : Distributivity: Ka(X->Y) -> (KaX -> KaY) This is modal logic which uses classical logic rules. KaX : a knows the that X is... more
Logic C#


C# convert a string for use in a logical condition?

Is it possible to convert a string to an operator for use in a logical condition. For example if(x Convert.ToOperator(">") y) {} or if(x ">" as Operator y){} I appreciate that this... more


Determine the sign of a 32 bit int?

Using ONLY: ! ~ & ^ | + << >> NO LOOPS I need to determine the sign of a 32 bit integer and I need to return 1 if positive, 0 if 0 and -1 if negative. Any ideas? I first... more
Logic C++ C Algorithm


Digit-increasing number test?

A number is called digit-increasing if it is equal n + nn + nnn + ... for some digit n between 1 and 9. For example 24 is digit-increasing because it equals 2 + 22 (here n = 2). Actually, a friend... more


Why is ''>0 True in Python?

In Python 2.6.4: >> ''>0 True Why is that?


python build a dynamic growing truth table?

My question is simple: "how to build a dynamic growing truth table in python in an elegant way?" for n=3 for p in False, True: for q in False, True: for r in False, True: print '|{0} | {1} |... more


Check severeal boolean returns in same time?

I have several bool elements and I am checking it if returns me false. bool i = false; switch (idcount) { case 1: i = p1(); break; case 2: i = p1() & p2(); break; case 3: i = p1() &... more


Can we implement a doubly-linked list using a single pointer?

I want to use a structure like: struct node { char[10] tag; struct node *next; }; I want to use the above structure to create a doubly-linked list. Is that possible and if yes, then how I can... more

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.