k = (a + b > 20) ? a + 3 * b : a – b;
Using if-else:
if (a + b > 20) {
k = a + 3 * b;
} else {
k = a – b;
}
Related Questions:
- Differentiate between if and if-else selection structures.
- Differentiate between else-if and switch selection structures.
- What is a nested selection structure?
- What are the rules for specifying a variable name in C language?
- What is a preprocessor directive? Explain #include preprocessor directive in detail.
- What is a pointer in C?
- Explain the difference between a while loop and a do-while loop.
- What are the different types of storage classes in C?
- How does a switch statement work in C?
- What is the difference between = and == operators in C?
- Explain different types of loops in C with examples.
- Describe the concept of functions in C and explain different types of functions.
- What is dynamic memory allocation in C? Explain malloc(), calloc(), and free() functions with examples.
- Why is a format specifier used? Explain with examples.
- Why is an escape sequence used? Explain with examples.
- What is the purpose of the printf() function? Explain with an example.
- Differentiate between printf() and scanf() functions.
- Evaluate the following expressions:
- What will be the output of the following program?
- What will be the output of the following program?