Drill on chapter, proof*

Hello, Thank for the help in past. I have completed the drill/test from the book. It work beautiful on executed. But I would like for you guys to tell me if there is anything I need to change or improve. Such as correctly way to write or clean up the line. However this practice I did is from 3 chapter of Bjarne Stroustrup book. I only type there what I learned from the 3 chapters.

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  #include "Std_lib_facilities.h"

int main()

{
		cout << "Hello! Please type your first name.\n";
		
	string first_name;
	
				cin >> first_name;
			
		cout << "\n";
		
		cout << "Hi " << first_name <<"\n";
		
		cout << "\n";
	
		cout << "Please enter first name you want to write to.\n";
		
				cin >> first_name;
			
		cout << "\n";
		
		cout << "Dear " << first_name << "," << "\n";
		
		cout << "\n";
		
		cout << "\n";
		
		cout << "How are you? What have you been doing these day?\n";
		
		cout << "\n";
	
		
		cout << "Is there any other friend you would like to write?\n";
		
		cout << "\n";
	
	string friend_name;
	
				cin >> friend_name;
	
		cout << "\n";
	
		cout << "Have you seen " << friend_name << "?" <<"\n";
		
		cout << "\n";
	
		cout << "Enter m if your friend is male, enter f if your friend is female.\n";
		
	char friend_sex;
	
				cin >> friend_sex;
			
			if(friend_sex =='m')
			
		cout << "If you see " << friend_name << " please ask him to call me.\n";
			
			
			if(friend_sex =='f')
			
		cout << "if you see " << friend_name << " please ask her to call me.\n";
		
		cout << "\n";
		
		cout << "What's your age?\n";
		
	int age;
	
				cin >> age;
			
		cout << "I heard you just had a birthday and you are " << age << " year old\n";
		
			if(age <= 0)simple_error("You are kidding");
			
		cout << "\n";
		
			if(age < 12)
		
		cout << "Next year you will be " << age+1 << "\n";
		
			if(age == 17)
			
		cout << "Next year you will be able to vote.";
		
			if(age >= 70)
			
		cout << "I hope you are enjoying retirement.";
		
		
	
	
		
	
	}


edited, fixed the mistake you gave. Thanks It look cleaner and clearly now.
Last edited on
Lines 12,24,67,70: You have extraneous pairs of {}. They do no harm, but do tend to imply to the reader that they are a conditional block of some sort (which they are not).

Line 7,15: first_name is declared twice. This is not currently causing an error because the second declaration is in a nested scope. If you're using these variables for different purposes (your name, first friend name), they should have different variable names.




Topic archived. No new replies allowed.