I want to solve a particular code using ternary operator alone. I also tried it,it also works fine , you can see that code below | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I want to solve a particular code using ternary operator alone. I also tried it,it also works fine , you can see that code below

Please tell me,is my code is good enough ? Or I need to improve my code like indentation, declaration etc Please note that: problem should be solved only using ternary operator https://code.sololearn.com/coGuU3BdwZsh/?ref=app

4th Feb 2021, 5:13 AM
Yogeshwaran P
Yogeshwaran P - avatar
2 Answers
+ 3
You could use a single printf and pass the argument comditionally using the ternary operator, like so ` printf((iside1 == iside2 && iside2 == iside3)? "equilateral triangle":((iside1!=iside2 && iside2!=iside3 && iside1!=iside3)?"scalene triangle":"isosceles triangle")); ` but that won't make any difference except make your code like 1% more readable. I don't know where you got this problem, but using ternary operators like this is just dumb. It makes your code really unreadable without actually benefitting you greatly.
4th Feb 2021, 5:24 AM
XXX
XXX - avatar
0
Thank you XXX for yours reply and feedback about my code😃
8th Feb 2021, 8:12 AM
Yogeshwaran P
Yogeshwaran P - avatar