89 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
3
answers
106
views
Evaluate Postfix and Logical Operators in C with no short-circuiting approach
I came across this question when studying logical operators and conditionals in C.
#include <stdio.h>
int main() {
int x = 3;
int y = 2;
int z = 3;
printf("Result #4 = %d\n&...
0
votes
1
answer
105
views
How to change a bool from true to false using an if statement that has user input as its condition?
Header file:
#include <iostream>
#include <string>
std::string correctText = "\nCorrect! +";
std::string incorrectText = "False!\n";
std::string answer = "paris&...
-2
votes
2
answers
160
views
Conditional statement `if ( ( i != '7' ) && ( j != '8' ) && ( k != '9' ) )` yields erratic results [closed]
#include <unistd.h>
void triplet(void);
int main(void)
{
triplet();
}
void triplet(void)
{
char i, j, k;
i = '0';
j = '1';
k = '2';
while (i < j)
{
i + ...
0
votes
2
answers
93
views
if-else unpredictable behaviour
I am trying to write a basic C program to display contents of a file on the screen.
I am facing a problem with the way if-else seems to work. Here are two codes which I think should work the same, but ...
3
votes
5
answers
513
views
Consolidating multiple OR and AND conditions in R
I want to consolidate multiple OR and AND conditions in R. I think x1 == 1 | x1 == 2 can be consolidated as x1 %in% c(1, 2). I'm wondering how x1 == 1 | y1 == 1 and x1 == 1 & y1 == 1 can be ...
0
votes
3
answers
1k
views
How to use "AND" operators in SAS Macro?
I recently coded a macro to create multiple "Proc freqs" easily, having to enter simply the variables and the condition "where" (if there is one).
It generally works, still I've ...
1
vote
1
answer
213
views
& performance difference (lazy evaluation) from R 4.2.0 to R 4.3.1
This code below benchmarks the & operation given opposite conditions that benefit or not from lazy evaluation conditions in the vectors.
set.seed(1)
N <- 1e6
V <- runif(N)
v1 <- V > 0....
1
vote
3
answers
190
views
How are logical expressions that include increment and decrement operators evaluated in C?
int a = 0, b= 1, c = 1;
if (c-- || ++a && b--)
I know that the precedence for && is the highest here. So what happens? Does it start from && and then looks at the expression ...
17
votes
2
answers
4k
views
difference between "&&" and "and" in kotlin
What's the difference between "&&" and "and" in kotlin?
in my code, when first condition is false, i've noticed that the condition after "and" is still evaluated ...
0
votes
1
answer
95
views
Why does the following expression in Javascript with logical AND operator is giving syntax Error?
While the expression is evaluating as expected for 1 && {} giving {} as the answer, however when I flip the operands to make it {} && 1 it gives syntax error.
452:1 Uncaught ...
1
vote
3
answers
122
views
Why is my C program not showing any output in the terminal when I try to find the youngest person's age among three given ages?
the terminal is showing no output (blank)
// if the ages of 3 people are put telling which one is youngest//
#include<stdio.h>
int main()
{
int a1,a2,a3;
printf("enter the age of ...
2
votes
4
answers
198
views
Can you change the value of a variable inside of a printf statement in C?
The following two problems I am having trouble with below are from chapter 5 exercise 3 in "C Programming a Modern Approach" by K.N. King.
1) i = 7; j = 8; k = 9;
printf("%d ",(...
-1
votes
2
answers
75
views
Why my codes 'if statement' doesn't work in C?
I wrote a program that you input your qualities and the program decides that if you are suitable for being astronaut.However, it works when taking the inputs and doesn't continue to the 'if statement' ...
1
vote
1
answer
71
views
If statement in a do while loop being ignored [closed]
I am trying to make a program that detects a user input and prints stuff based on that input. The input needs to have limits set however the if statements I set up are being ignored and I'm not quite ...
-1
votes
2
answers
109
views
Why isn't the ++y part executing? [duplicate]
So here is the question I am given , I need to tell the output :
#include <iostream>
using namespace std;
int main()
{
int x = 10;
int y = 20;
if(x++ > 10 && ++y > 20 ){...