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

Program to calculate gross pay and tax payable, Study the following table u...

Study the following table used to compute the tax payable by employees in certain organization   Gross Pay                                  Fewer than Three             Three

Coding, dispaly the last ant on rod

dispaly the last ant on rod

#title.faculty attendance system, how to create database of faculty databas...

how to create database of faculty database......... send me with program

Explain static member functions, Static Member Functions All the object...

Static Member Functions All the objects of the class share static data members of a class. The example above demonstrates how to keep track of all the objects of a class which

Create a program to word count, Create a program WordCount1Main.java doing ...

Create a program WordCount1Main.java doing the following:  For each word in the le word.txt { Create an object of the class Word { Add the object to a set of the type java.uti

Write a program that takes the image, Write a program that takes the image ...

Write a program that takes the image tracks.jpg and finds Canny edges, and then finds lines in these edges using the Hough transform. The easiest way to do this is to take the prog

C program for string address, C Program for STRING ADDRESS #include std...

C Program for STRING ADDRESS #include stdio.h> #include conio.h> #include string.h> void main() {           char *name;           int length;           cha

I need app design team wanted to new check-in app, New App Production compa...

New App Production company is seeking an organized and highly accomplished design team to prepare the first (and potentially more) of my companies' App concepts, intended completel

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