This is a basic C program that prompts the user to enter two integers (a and b) and then uses the ternary operator (? :) to determine which of the two values is the smallest. The ternary operator is a shorthand way of writing an if-else statement.
The program starts with the inclusion of the "stdio.h" header file, which contains the functions used for input and output (such as printf and scanf).
The main() function is the entry point of the program. It starts by declaring two variables, "a" and "b", to store the user-entered values. The program then uses the printf function to prompt the user to enter the first value and assigns the user input to the variable "a" using the scanf function. Similarly, the program prompts the user to enter the second value and assigns the user input to the variable "b" using the scanf function.
The ternary operator (? :) is used to check whether "a" is greater than "b". If it is, the program will print "First value is Smallest :%d", followed by the value of "a". If "a" is not greater than "b", the program will print "Second value is Smallest :%d", followed by the value of "b".
Finally, the program returns 0, indicating that the program has completed successfully.
#include<stdio.h> int main() { int a,b; printf("\nEnter the First value:"); scanf("%d",&a); printf("\nEnter the Second value:"); scanf("%d",&b); a>b?printf("First value is Smallest :%d",a):printf("Second value is Smallest :%d",b); return 0; }To download raw file Click Here
Enter the First value: 3 Enter the Second value: 5 First value is Smallest : 3
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions