-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayone.cpp
More file actions
30 lines (26 loc) · 963 Bytes
/
arrayone.cpp
File metadata and controls
30 lines (26 loc) · 963 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
// small arrays of integer
#include <iostream>
int main(int argc, char const *argv[]) {
int yams[3];
yams[0] = 7;
yams[1] = 8;
yams[2] = 6;
int yamcosts[3] = {20, 30, 5};
std::cout << "Total yams = "
<< yams[0] + yams[1] + yams[2]
<< '\n';
std::cout << "The package with "
<< yams[1] << " yams costs "
<< yamcosts[1] << " cents per yam."
<< '\n';
std::cout << "The total yam expense is "
<< yams[0] * yamcosts[0] + yams[1] * yamcosts[1] + yams[2] * yamcosts[2]
<< " cents."
<< '\n';
std::cout << "Size of yams array = " << sizeof yams << "bytes." << '\n';
std::cout << "Size of one element = " << sizeof yams[0] << "bytes." << '\n';
std::cout << "Size of double " << sizeof(double) << '\n';
std::cout << "Size of long double " << sizeof(long double) << '\n';
std::cout << "Size of long long " << sizeof(long long) << '\n';
return 0;
}