add chapter 2

This commit is contained in:
kuoi 2022-08-23 18:47:13 +01:00
parent bc81913469
commit 6ce7b718d1
7 changed files with 88 additions and 0 deletions

12
ch2/01.cpp Normal file
View File

@ -0,0 +1,12 @@
# include <iostream>
using namespace std;
int main(){
string your_name, your_adress;
cout << "Enter Your Name" << endl;
cin >> your_name;
cout << "Enter Your Adress" << endl;
cin >> your_adress;
cout << "Your Name: " << your_name << endl <<"Your Adress: " << your_adress << endl;
return 0;
}

11
ch2/02.cpp Normal file
View File

@ -0,0 +1,11 @@
# include <iostream>
using namespace std;
int main(){
int long_value, ma_value;
cout << "Enter Long" << endl;
cin >> long_value;
ma_value = 220 * long_value;
cout << "Ma is " << ma_value << endl;
return 0;
}

15
ch2/03.cpp Normal file
View File

@ -0,0 +1,15 @@
# include <iostream>
using namespace std;
void Double_wd (string b, string c);
int main(){
Double_wd ("Three blind mice", "See how they run");
return 0;
}
void Double_wd (string b, string c){
string wd1, wd2, wd3;
wd1 = b;
wd2 = c;
cout << wd1 << endl << wd1 << endl << wd2 << endl << wd2 << endl;
}

11
ch2/04.cpp Normal file
View File

@ -0,0 +1,11 @@
# include <iostream>
using namespace std;
int main(){
int yr_value, mn_value;
cout << "Enter Your Eage" << endl;
cin >> yr_value;
mn_value = 12 * yr_value;
cout << "It contains " << mn_value << " Months"<< endl;
return 0;
}

11
ch2/05.cpp Normal file
View File

@ -0,0 +1,11 @@
# include <iostream>
using namespace std;
int main(){
double ce_value, fa_value;
cout << "Enter Celsisus value: ";
cin >> ce_value;
fa_value = 1.8 * ce_value + 32;
cout << ce_value << "degree Celsisus is " << fa_value << " degrees Fahrenheit" << endl;
return 0;
}

11
ch2/06.cpp Normal file
View File

@ -0,0 +1,11 @@
# include <iostream>
using namespace std;
int main(){
double ly_value, au_value;
cout << "Enter the number of light years: ";
cin >> ly_value;
au_value = int(63240 * ly_value);
cout << ly_value << " light years = " << au_value << " astronomical unites" << endl;
return 0;
}

17
ch2/07.cpp Normal file
View File

@ -0,0 +1,17 @@
# include <iostream>
using namespace std;
void time_output(int h, int m);
int main(){
int h, m;
cout << "Enter the number of hours: ";
cin >> h;
cout << "Enter the number of minutes: ";
cin >> m;
time_output(h,m);
return 0;
}
void time_output(int h, int m){
cout << "Time: " << h << ":" <<m << endl;
}