Here is a sample program that I wrote in C++ to show how to use ternary operator. The code is very simple and easy to understand.
Program Listing
#include <iostream>
using namespace std;
main() {
for(;;) {
int number=0,value=0;
system("cls");
cout << "Enter a Number :=> ";
cin >> number;
if (number==0) {
cout << "\n\n";
cout << "\t Thank You For Using This Program";
break;
}
value = (number >=10 ? 20:10);
cout << "\n\n";
cout << "The resulting value is "
<< value << ".";
cout << "\n\n";
system("pause");
}
cout << "\n\n";
system("pause");
}
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
#include <iostream>
using namespace std;
main() {
for(;;) {
int number=0,value=0;
system("cls");
cout << "Enter a Number :=> ";
cin >> number;
if (number==0) {
cout << "\n\n";
cout << "\t Thank You For Using This Program";
break;
}
value = (number >=10 ? 20:10);
cout << "\n\n";
cout << "The resulting value is "
<< value << ".";
cout << "\n\n";
system("pause");
}
cout << "\n\n";
system("pause");
}
This is my passion and i have also a lot of tutorials about this topic and your salon and work is good. Thank you very for share us such kind of good info
ReplyDelete