if (x > y)
z = (x + y) * 3;
else
z = x – 5 * y;
Using the conditional operator:
z = (x > y) ? (x + y) * 3 : x – 5 * y;
Related Questions:
- Differentiate between if and if-else selection structures.
- Differentiate between else-if and switch selection structures.
- What is a nested selection structure?
- Write the following statement using the if-else statement.
- 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?