I wrote this program that will ask the user to give two numbers and then the program will check which of the two number has a bigger value using Ternary operator and display the results on the screen using C++.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod City I also accepting computer repair, networking and Arduino Project development at a very affordable price.
Sample Program Output
Program Listing
bigger.cpp
// bigger.cpp
// Author : Jake Rodriguez Pomperada
// Date : October 23, 2019
#include <iostream>
using namespace std;
int bigger(int a,int b);
int main()
{
int num1=0, num2=0;
cout <<"\n\n";
cout <<"\tBigger Between Two Numbers in C++";
cout <<"\n\n";
cout<<"\tEnter first number :";
cin>>num1;
cout<<"\tEnter second number :";
cin>>num2;
cout <<"\n";
bigger(num1,num2);
cout <<"\n\n";
cout <<"\tEnd of Program";
}
int bigger(int a, int b)
{
int big=0;
big = a > b ? a : b;
if(a>b)
{
big = a;
cout<<"\tFirst number "<<big<<" is the largest";
}
else if (b>a)
{
big = b;
cout<<"\tSecond number "<<big<<" is the largest";
}
if (a==b) {
cout <<"\tBoth numbers as equal to one another.";
}
}
No comments:
Post a Comment