Conditional and Ternary operator ( ?, : )

 Conditional and Ternary operator ( ?, : )

Conditional and Ternary operator is used to check the condition at that place of it by using this operator we can  minimize the length of the program because true part and false part of condition is written in a single line.

Syntax 

(condition )? true part : false part 

Conditional or Ternary Operator (?:) in C/C++ - GeeksforGeeks

Examples:--

/*Program to find the largest no among two number using conditional and ternary operator  */

#include<stdio.h>

#include<conio.h>

main()

{        int a,b;

          clrscr();

          printf(" \n Enter the value for a and b = \n");

          scanf("%d%d",&a,&b);

          (a>b)?printf("%d is largest ",a) : printf("%d is largest ",b);

         getch();

}


/*    Output:--

                    Enter the value for a and b =20

                                                                  10

                    20 is largest

*/

         

 flowchart :--


       

                                                        💬💭😀👇

No comments:

Post a Comment

This Blog helps you to learn basics to high level programming coding and practicals.
conceptual understanding

c program, Advance coding, c++ program, simple program, Advance language

online quiz Application project page MCA final year project

  Here we making a quiz application ppt presentation for college project so that our project idea will like to our professor and teacher  fi...