Write a program to demonstrate conditional operator

//this is a program to demonstrate conditional operator
#include<iostream>
#include<conio.h>

using namespace std;

int main()
{
int small,num1,num2;

cout<<"\n\nEnter any 2 numbers: ";
cin>>num1>>num2;

small=(num1<num2)?num1:num2;

cout<<"\n\nThe number "<<small<<" is a smallest number.";

getch();
}

Previous
Next Post »