Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- using namespace std;
- void swap(int* a, int* b)
- {
- int buf = *a;
- *a = *b;
- *b = buf;
- }
- void swap(int& a, int& b)
- {
- int buf = a;
- a = b;
- b = buf;
- }
- void swap2(int a, int b)
- {
- int buf = a;
- a = b;
- b = buf;
- }
- int sum(int* a,int b)
- {
- return *a + b;
- }
- int dif(int& a,int* b)
- {
- return a - *b;
- }
- void mult(int* a,int& b,int& res)
- {
- res = *a * b;
- }
- void div(int& a,int* b,double& res)
- {
- res = (double)a / *b;
- }
- int main()
- {
- /*int g = 233;
- int* p = &g;
- cout << g << endl;
- cout << &g << endl;
- cout << *p << endl;
- int h = 12;
- int& r = h;
- r += 5;
- cout << h << endl;
- */
- int a = 0,
- b = 0,
- c = 0,
- res = 0;
- /*cin >> a >> b;
- swap2(a, b);
- cout << a << " " << b << endl;
- swap(&a,&b);
- cout << a << " " << b << endl;
- swap(a,b);
- cout << a << " " << b << endl;*/
- double resDiv = 0;
- cout << "Enter first number: ";
- cin >> a;
- cout << "Enter second number: ";
- cin >> b;
- cout <<a<<" + "<<b<<" = "<< sum(&a,b)<<endl;
- cout <<a<<" - "<<b<<" = "<< dif(a,&b)<<endl;
- mult(&a,b,res);
- cout <<a<<" * "<<b<<" = "<<res<<endl;
- div(a,&b,resDiv);
- cout <<a<<" / "<<b<<" = "<<setprecision(2)<<resDiv<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement