-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut2.cpp
More file actions
50 lines (39 loc) · 1.89 KB
/
Copy pathtut2.cpp
File metadata and controls
50 lines (39 loc) · 1.89 KB
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
#include <iostream>
#include <climits>
// #include <cfloat>
int main()
{
// sizeof operator
std::cout<<"The size of char is "<<sizeof(char) <<" bytes."<< std::endl;
std::cout<<"The size of int is "<<sizeof(int) <<" bytes."<< std::endl;
std::cout<<"The size of double is "<<sizeof(double) <<" bytes."<< std::endl;
std::cout<<"The size of unsigned int is "<<sizeof(unsigned int) << " bytes."<<std::endl;
std::cout<<"The size of short is "<<sizeof(short) << " bytes."<<std::endl;
std::cout<<"The size of long is "<<sizeof(long) << " bytes."<<std::endl;
std::cout<<"The size of long long is "<<sizeof(long long) <<" bytes."<< std::endl;
std::cout<<"The size of float is "<<sizeof(float) <<" bytes."<< std::endl;
std::cout<<"The size of double is "<<sizeof(double) <<" bytes."<< std::endl;
std::cout<<"The size of long double is "<<sizeof(long double) <<" bytes."<< std::endl;
std::cout<<"The minimum value of char is "<<CHAR_MIN <<std::endl;
std::cout<<"The minimum value of int is "<<INT_MIN <<std::endl;
std::cout<<"The minimum value of short is "<<SHRT_MIN <<std::endl;
std::cout<<"The minimum value of long is "<<LONG_MIN <<std::endl;
std::cout<<"The minimum value of long long is "<<LONG_LONG_MIN <<std::endl;
int age {21};
std::cout<<"The size of age is "<<sizeof(age) <<" bytes."<< std::endl;
std::cout<<"The size of age is "<<sizeof age <<" bytes."<< std::endl;
// What is a constant?
const int months_of_year {12};
std::cout<<months_of_year<<std::endl;
// literal constant
std::cout << "Hello\tthere\nmy friend\n"<<std::endl;
int x = 12;
float y = 1.56;
// const double pi {3.1415926};
// Preprocessor, dont use constant like this in modern c++
#define pi 3.1415926
std::cout<<"The value of pi is "<<pi<<std::endl;
// Arrays
// int test_scores [5];
return 0;
}