File tree 3 files changed +70
-0
lines changed 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ int main ()
4
+ {
5
+ using namespace std ;
6
+ int yams[3 ];
7
+
8
+ yams[0 ] = 7 ;
9
+ yams[1 ]= 8 ;
10
+ yams[2 ] = 6 ;
11
+
12
+ int yamcosts[3 ] = {20 , 30 , 5 };
13
+
14
+ cout << " Total yams = " ;
15
+ cout << yams[0 ] + yams[1 ] + yams[2 ] << " yams cost " ;
16
+ cout << " The package with " << yams[1 ] << " yams costs " ;
17
+ cout << yamcosts[1 ] << " cents per yam.\n " ;
18
+ int total = yams[0 ] * yamcosts[0 ] + yams[1 ] * yamcosts[1 ];
19
+ total = total + yams[2 ] * yamcosts[2 ];
20
+
21
+ cout << " The total yam expense is " << total << " cents.\n " ;
22
+ cout << " \n Size of yams array = " << sizeof yams;
23
+ cout << " bytes.\n " ;
24
+ cout << " Size of one element = " << sizeof yams[0 ];
25
+ cout << " bytes.\n " ;
26
+
27
+ return 0 ;
28
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ int main ()
4
+ {
5
+ using namespace std ;
6
+ const int ArSize = 20 ;
7
+ char name[ArSize];
8
+ char dessert[ArSize];
9
+
10
+ cout << " Enter your name:\n " ;
11
+ cin.getline (name, ArSize);
12
+ cout << " Enter your favorite dessert: \n " ;
13
+ cin.getline (dessert, ArSize);
14
+
15
+ cout << " I have some delicious " << dessert;
16
+ cout << " for you, " << name << " .\n " ;
17
+
18
+ return 0 ;
19
+ }
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ int main ()
4
+ {
5
+ using namespace std ;
6
+ int auks, bats, coots;
7
+ auks = 19.99 + 11.99 ;
8
+
9
+ bats = (int ) 19.99 + (int ) 11.99 ;
10
+ coots = int (19.99 ) + int (11.99 );
11
+
12
+ cout << " auks = " << auks << " , bats = " << bats;
13
+ cout << " , coots = " << coots << endl;
14
+
15
+ char ch = ' Z' ;
16
+ cout << " The code for " << ch << " is " ;
17
+ cout << int (ch) << endl;
18
+ cout << " Yes, the code is " ;
19
+ cout << static_cast <int >(ch) << endl;
20
+
21
+ return 0 ;
22
+
23
+ }
You can’t perform that action at this time.
0 commit comments