New Update Launched Contact Us Download Now!

Algorithm and flowchart to find the largest of two numbers using ternary operator in C with source code

Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

THEORY

The stdio.h denotes the C library that we have connected this program to, which contains the code to execute the printf command and display results. The printf keyword is used to display content on the screen. It can be used to display strings, numbers as well as values of variables, etc. The scanf command is used to read user input and is used to accept the value of the circle radius from the user. A condion is used to check whether the number is larger or not. The condition operator used here is the ternary operator. Its syntax is: (condition)?true statement:false statement;

Algorithm and flowchart to find the largest of two numbers using ternary operator  in C with source code

FLOWCHART
flowchart to find the largest of two numbers using ternary operator  in C

Algorithm

Step 1: Start
Step 2: Read a,b
Step 3: If a>b then follow step 4 else step 5
Step 4: Print a is largest
Step 5: Print b is largest
Step 6: Stop
C Source Code

//Written By DataVoid Team
#include<stdio.h>
 void main()
 { 
   int a,b;
   printf("\n Enter two numbers:");  
   scanf("%d%d",a,b);
   (a>b)?printf("\n The largest is %d",a):printf("\n The largest is %d",b);
 }

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.