A very simple program that I wrote in C++ way back in 2010 in my C++ programming class in college to check if the user is old enough I am using array as my data structure and if conditional statement in C++.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Program Listing
#include <iostream>
#include <iomanip>
using namespace std;
struct item {
string name[2];
int age[2];
};
main()
{
item child;
cout << "\t\t Determine Old Age ";
cout << "\n\n";
for (int x=0; x<2; x++) {
cin.ignore();
cout << "\nEnter the Child's Name : ";
getline(cin,child.name[x]);
cout << "\nEnter the Child's Age : ";
cin >> child.age[x];
}
cout << "\n\n";
if (child.age[0] > child.age[1]) {
cout << "\n\n";
cout << child.name[0] << " is much older compared to "
<< child.name[1];
}
else {
cout << "\n\n";
cout << child.name[1] << " is much older compared to "
<< child.name[0];
}
cout << "\n\n";
system("pause");
}
No comments:
Post a Comment