Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



What is the data type of the following expression:  
expr₁ ? expr₂ : expr₃  
if expr₁ is of type float & expr₂ is of type int.





Solution

Solution: In the **ternary operator** `(expr₁ ? expr₂ : expr₃)`, the **data type of result** is the **common type** of `expr₂` and `expr₃`. Here, - `expr₁` → condition (float type, irrelevant for result type) - `expr₂` → int - `expr₃` → (not specified but implied same as expr₂ type logic) When int and float are combined → **result type = float** (implicit type conversion).


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...