It kind of seems like an abstract if statement, where ? checks for truth and : is else... is that so?

Yeah, almost. It's called the "conditional operator" (sometimes not entirely accurately referred to as "the ternary operator", since it's the only ternary operator in C). It's not a statement though, it's an expression, it has a value. It evaluates to its second argument if the first argument evaluates to true, and to its third argument if it's false. Therefore

sign = (s[i] == '-') ? -1 : 1;

is equivalent to

if (s[i] == '-') {
    sign = -1;
} else {
    sign = 1;
}
Answer from user529758 on Stack Overflow
🌐
Unstop
unstop.com › home › blog › ternary (conditional) operator in c (+code examples)
Ternary (Conditional) Operator In C (+Code Examples)
December 26, 2023 - The ternary operator in C language, also known as the conditional operator, is denoted by the question mark and colon symbols, i.e., (? :). It is a powerful operator that provides a shorthand way of expressing conditional assignment statements, ...
🌐
Lonely Binary
lonelybinary.com › en-us › blogs › learn › ternary-operator
Ternary Operator in Arduino C++ Language – Lonely Binary
November 16, 2023 - The Ternary Operator provides a shorthand method to express simple if-else statements. This operator consists of a question mark (?) and a colon (:). This operator perform an operation that evaluates a condition and returns one value if the ...
People also ask

What is the purpose of the C# Double Question Mark Operator?
The purpose of the C# Double Question Mark Operator, also known as the Null Coalescing Operator, is to provide a concise way to assign default values when dealing with null references. It simplifies code by returning the left-hand operand if it's not null, otherwise it returns the right-hand operand.
🌐
ironpdf.com
ironpdf.com › ironpdf blog › .net help › c# double question mark
C# Double Question Mark (How It Works For Developers)
How is the Double Question Mark Operator used in method parameters?
In method parameters, the Double Question Mark Operator is used to assign default values, ensuring that methods can handle null inputs gracefully and maintain functionality even with missing arguments.
🌐
ironpdf.com
ironpdf.com › ironpdf blog › .net help › c# double question mark
C# Double Question Mark (How It Works For Developers)
How do C# PDF libraries integrate with the Double Question Mark Operator?
C# PDF libraries can integrate the Double Question Mark Operator to manage default settings and handle null values efficiently during the conversion of HTML to PDF, improving both functionality and user experience.
🌐
ironpdf.com
ironpdf.com › ironpdf blog › .net help › c# double question mark
C# Double Question Mark (How It Works For Developers)
🌐
IronPDF
ironpdf.com › ironpdf blog › .net help › c# double question mark
C# Double Question Mark (How It Works For Developers)
June 23, 2025 - Enter the Double Question Mark Operator (??), a powerful feature designed to streamline the Null Coalescing Operator. New developers often come up with a question mark at what this Double Question Mark Operator means.
🌐
Cppreference
en.cppreference.com › w › cpp › language › operator_other.html
Other operators - cppreference.com
March 5, 2025 - The conditional operator (colloquially referred to as ternary conditional ) checks the boolean value of the first expression and, depending on the resulting value, evaluates and returns either the second or the third expression.
🌐
Programiz
programiz.com › c-programming › ternary-operator
C Ternary Operator (With Examples)
We use the ternary operator to run one code when the condition is true and another code when the condition is false. In this tutorial, you'll learn about the working of ternary operator in C programming with the help of examples.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › c language › conditional-or-ternary-operator-in-c
Conditional or Ternary Operator (?:) in C - GeeksforGeeks
July 12, 2025 - Since the Conditional Operator '?:' takes three operands to work, hence they are also called ternary operators.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › operators-in-c
Operators in C - GeeksforGeeks
Interview Questions · Examples · Quizzes · Projects · Cheatsheet · File Handling · Multithreading · Memory Layout · DSA in C · C++ Last Updated : 1 Nov, 2025 · Operators are the basic components of C programming. They are symbols that represent some kind of operation, such as mathematical, relational, bitwise, conditional, or logical computations, which are to be performed on values or variables.
Published   November 1, 2025
🌐
Quora
quora.com › What-does-the-question-mark-mean-in-C
What does the question mark mean in C? - Quora
Answer (1 of 7): The ‘?’ is used in ternary operator. Example: (x > y) ? x : y It can be also written as: if(x > y) { printf(“%d”,x); } else { printf(“%d”,y); } Both example are the same but the ternary operator is used for simplicity ...
🌐
Mathbits
mathbits.com › MathBits › CompSci › looping › operator2.htm
Conditional Operator for C++
Conditional Operator · You can exchange simple if-else code for a single operator the conditional operator. The conditional operator is the only C++ ternary operator (working on three values). Other operators you have seen are called binary operators (working on two values)
🌐
freeCodeCamp
freecodecamp.org › news › how-the-question-mark-works-in-javascript
How the Question Mark (?) Operator Works in JavaScript
February 3, 2021 - By Nishant Kumar The conditional or question mark operator, represented by a ?, is one of the most powerful features in JavaScript. The ? operator is used in conditional statements, and when paired with a :, can function as a compact alternative ...
🌐
PCMAG
pcmag.com › home › encyclopedia › q
Definition of question mark | PCMag
In C programming, the question mark is used as a conditional symbol. For example, in the expression x1 ?
🌐
Silvrback
tim.silvrback.com › c-question-mark-operators
Tim Leffelman - C# Question Mark Alias and Operators
December 10, 2015 - In the case of y, it would then check e. But, in the case of z, it would return null (because c is null) without consideration for e. Basically, if you find yourself trying mix too many different question mark operators, or trying to do something other then one of the following things with the ??, then you're probably doing something wrong:
🌐
University of Washington
courses.washington.edu › css342 › zander › css332 › datatypes.html
C/C++ data types, basic operators, and control structures
char s[] = "hello"; Basic operators The basic operators are the same as in Java, e.g., +, -, *, /, %, ++, --, etc. The question mark operator, ?:, is also found in C++. Some people call it the ternary operator because it is the only operator in C++ (and Java) that takes three operands.
🌐
Wikipedia
en.wikipedia.org › wiki › Ternary_conditional_operator
Ternary conditional operator - Wikipedia
January 27, 2026 - Typical syntax for an expression using the operator is like if a then b else c or a ? b : c. One can read it aloud as "if a then b otherwise c". The form a ? b : c is the most common, but alternative syntax exists. For example, Raku uses the syntax a ?? b !! c to avoid confusion with the infix ...
🌐
W3Schools
w3schools.com › c › c_conditions_short_hand.php
C Short Hand If ... Else (Ternary Operator)
C Examples C Real-Life Examples C Exercises C Quiz C Code Challenges C Compiler C Syllabus C Study Plan C Interview Q&A C Certificate ... There is also a short-hand if...else, known as the ternary operator because it uses three operands.
🌐
Hero Vired
herovired.com › learning-hub › topics › ternary-operator-in-c
Ternary Operators in C : Examples and Syntax - Hero Vired
January 21, 2025 - Explore ternary & conditional operators in C with examples, syntax, and a C program to find the largest of three numbers, advantages, disadvantages, and differences.
🌐
Wikipedia
en.wikipedia.org › wiki › Regular_expression
Regular expression - Wikipedia
1 week ago - Parentheses are used to define the scope and precedence of the operators (among other uses). For example, gray|grey and gr(a|e)y are equivalent patterns which both describe the set of "gray" or "grey". ... A quantifier after an element (such as a token, character, or group) specifies how many times the preceding element is allowed to repeat. The most common quantifiers are the question mark ?, the asterisk * (derived from the Kleene star), and the plus sign + (Kleene plus).