What is the conditional expression operator, C/C++ Programming

Assignment Help:

The Conditional Expression Operator

An alternate method to using a simple if-else construct is the conditional expressions operator, ?:

 

A conditional expression operator is a ternary operator, it has three operand, whose general format is:

 

expression1 ? expression2 : expression3

 

Here the expression1 is evaluated first, if it is true then the expression 2 is the value of the conditional operator, otherwise the expression 3 is the value.

 

e.g.

                The if else construct

 

if(a>b)

 {

z = a;

 }

else

 {

                z = b;

                       }

 

                This can be written as

 

                                z = (a>b) ? a: b;

 


Related Discussions:- What is the conditional expression operator

COMPUTER, THEORY OF COMPUTER PROGRAMMING

THEORY OF COMPUTER PROGRAMMING

C program to check prime numbers , C Program to check PRIME NUMBERS   ...

C Program to check PRIME NUMBERS   main() {           int i,k,r,flag;           clrscr();           printf("ENTER THE NO. TO CHECK IT IS PRIME OR NOT: ");

Coding, padovan series with words

padovan series with words

Constructor , What is constructor or ctor? need help

What is constructor or ctor? need help

Give example of the do while loop, Normal 0 false false fal...

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

Require flowchart, I require a flowchart for push , & pop operation on stac...

I require a flowchart for push , & pop operation on stack using array

#padovan string, write a java program padovan string program in java ...

write a java program padovan string program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class Pado

Describe about the container class, Describe about the container class. ...

Describe about the container class. -Class to hold objects in external storage or memory. It acts as a generic holder. - It has a predefined behaviour and a known interface.

Explain compound assignment operators, Compound Assignment Operators Ap...

Compound Assignment Operators Apart from the binary and the unary arithmetic operators, we also have compound assignment operators. These are +=, -=, *=, /=, %=. Using these op

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd