Skip to content

Commit ca5360a

Browse files
committed
local
1 parent 4824965 commit ca5360a

File tree

12 files changed

+194
-2
lines changed

12 files changed

+194
-2
lines changed

18-Programming-4kids/06_homework_08_answer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using namespace std;
44
int main() {
55

66
int days;
7-
while(true) {
7+
88
cin >> days;
99

1010
int years = days / 360;
@@ -14,7 +14,7 @@ int main() {
1414
days = days % 30;
1515

1616
cout<<years<<" "<<months<<" "<<days<<"\n";
17-
}
17+
1818

1919
return 0;
2020
}

18-Programming-4kids/11_01.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
char ch1 = 'A';
6+
int ch_value = ch1;
7+
8+
cout<<ch_value<<"\n";
9+
cout<<(int)'A'<<"\n";
10+
cout<<(int)'B'<<"\n";
11+
cout<<(int)'C'<<"\n";
12+
cout<<(int)'Z'<<"\n";
13+
cout<<(int)'A' + 26 - 1<<"\n";
14+
15+
char ch2 = 90;
16+
cout<<ch2<<"\n";
17+
18+
cout<<"***\n";
19+
20+
cout<<(int)'a'<<"\n";
21+
cout<<(int)'b'<<"\n";
22+
cout<<(int)'c'<<"\n";
23+
cout<<(int)'z'<<"\n";
24+
cout<<(int)'a' + 26 - 1<<"\n";
25+
26+
cout<<('A' < 'a')<<"\n";
27+
return 0;
28+
}
29+

18-Programming-4kids/11_02.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
char ch1 = 'D';
6+
7+
if ('A' <= ch1 && ch1 <= 'Z') {
8+
cout << ch1 << " is an upper case\n";
9+
ch1 = ch1 - 'A' + 'a';
10+
cout << ch1 << " now is a lower case\n";
11+
} else if ('z' <= ch1 && ch1 <= 'z')
12+
cout << ch1 << " is already a lower case\n";
13+
else if ('0' <= ch1 && ch1 <= '9')
14+
cout << ch1 << " is a digit\n";
15+
else
16+
cout << ch1 << " is neither a digit nor a letter\n";
17+
18+
return 0;
19+
}
20+

18-Programming-4kids/11_03.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
string name = "Hany";
6+
7+
int sz = name.size(); // called function/method
8+
cout << sz << "\n"; // 4
9+
10+
cout << name << "\n";
11+
12+
for (int i = 0; i < sz; ++i)
13+
cout << name[i]; // internally array
14+
15+
return 0;
16+
}
17+

18-Programming-4kids/11_04.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int numbers[5] = { 1, 2, 3, 4, 5 };
6+
7+
char name1[5] = { 'H', 'a', 'n', 'i' }; // 5 not 4
8+
char name2[5] = "Hani";
9+
10+
string name3 = "Hani";
11+
12+
cout << name1 << "\n";
13+
cout << name2 << "\n";
14+
cout << name3 << "\n";
15+
16+
return 0;
17+
}
18+

18-Programming-4kids/11_05.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
6+
char name1[4];
7+
name1[0] = 'H';
8+
name1[1] = 'a';
9+
name1[2] = 'n';
10+
name1[3] = 'i';
11+
12+
cout << name1 << "\n";
13+
14+
return 0;
15+
}
16+

18-Programming-4kids/11_06.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
6+
char name1[5];
7+
name1[0] = 'H';
8+
name1[1] = 'a';
9+
name1[2] = 'n';
10+
name1[3] = 'i';
11+
name1[4] = '\0'; // Null character
12+
13+
cout << name1 << "\n";
14+
15+
return 0;
16+
}
17+

18-Programming-4kids/11_07.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
6+
char name1[5];
7+
name1[0] = 'H';
8+
name1[1] = '\0';
9+
name1[2] = 'n';
10+
name1[3] = 'i';
11+
name1[4] = '\0'; // Null character
12+
13+
cout << name1 << "\n";
14+
15+
return 0;
16+
}
17+

18-Programming-4kids/11_08.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
6+
string name1;
7+
getline(cin, name1);
8+
cout<<name1<<"\n";
9+
10+
char name2[50];
11+
cin.getline(name2, 50);
12+
cout<<name2<<"\n";
13+
14+
15+
return 0;
16+
}
17+

18-Programming-4kids/11_09.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main() {
5+
6+
// Array of names - each name is sequence of letters!
7+
string names[5] = {"Mostafa Saad", "Never Ever", "Hello world"};
8+
9+
for (int i = 0; i < 5; ++i)
10+
cout<<names[i]<<"\n";
11+
12+
return 0;
13+
}
14+

0 commit comments

Comments
 (0)