-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFILE2.cpp
More file actions
33 lines (27 loc) · 869 Bytes
/
FILE2.cpp
File metadata and controls
33 lines (27 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
The following program explains the concepts of class and object.
It accepts your name and age as input from standard input and displays it on the standard output.
It also checks the person's age and displays a message.
*/
#include <iostream>
using namespace std;
class person
{
public:
char name[16];
int age;
}; // end of class person
int main()
{
person myself;
cout << "Enter your name: " << endl;
cin >> myself.name; // 'cin' accepts input from the user. It is defined in the header file 'iostream'.
cout << "Your name is " << myself.name << endl;
cout << "Enter your age: " << endl;
cin >> myself.age;
cout << "Your age is " << myself.age << endl;
if(myself.age < 100) {cout << "You are pretty young!" << endl;}
if(myself.age == 100){cout << "You are old" << endl;}
if(myself.age > 100) {cout << "You are really old" << endl;}
return 0;
}