/* 8.write a program to enter two numbers and find the smallest out of them.
use conditional operator */
#include<stdio.h>
#include<conio.h>
void main()
{
int no1,no2,a;
clrscr();
printf("enter 1st number: ");
scanf("%d",&no1);
printf("\nenter 2nd number: ");
scanf("%d",&no2);
a = no1 < no2 ? no1 : no2;
printf("\n\n==========================");
printf("\nsmallest number is: %d",a);
printf("\n==========================");
getch();
}
/* output:
enter 1st number: 12
enter 2nd number: 13
==========================
smallest number is: 12
==========================
*/
No comments:
Post a Comment