What is conditional operators

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2009
Posts: 1
Reputation: komrul_raja009 is an unknown quantity at this point 
Solved Threads: 0
komrul_raja009 komrul_raja009 is offline Offline
Newbie Poster

What is conditional operators

 
0
  #1
Oct 28th, 2009
What is conditional operators ? Using conditional operator find a smallest number amongst two numbers ?
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 68
Reputation: crazyboy has a little shameless behaviour in the past 
Solved Threads: 0
crazyboy crazyboy is offline Offline
Junior Poster in Training
 
0
  #2
Oct 28th, 2009
Conditional operator is also called ternary operator and they are ? and :
Quetion mark and Collon.


int Num1,Num2;
int MinNum = Num1 < Num2 ? Num1 : Num2;
Cout << MinNum;

It Will give min number from two numbers num1 and num2;
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 353
Reputation: dkalita will become famous soon enough dkalita will become famous soon enough 
Solved Threads: 53
dkalita's Avatar
dkalita dkalita is offline Offline
Posting Whiz
 
0
  #3
Oct 28th, 2009
Adding to crazyboy:

It can be generalized as follows:

  1. expr?expr1:expr2;
MEANS
  1. if(expr)
  2. expr1;
  3. else
  4. expr2;
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC