Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning (disable:4996)
- #include <iostream>
- using namespace std;
- void uvecaj(int* a, int *b)
- {
- (*a)++;
- (*b)++;
- cout << "U funkciji uvecaj vrijednosti varijabli su: " << endl;
- cout << "a: " << *a << endl;
- cout << "b: " << *b << endl;
- cout << "-------------------------" << endl;
- }
- int main()
- {
- int a = 6;
- int b = 7;
- cout << "Main prije poziva funkcije uvecaj: " << endl;
- cout << "a: " << a << endl;
- cout << "b: " << b << endl;
- cout << "-------------" << endl;
- uvecaj(&a, &b);
- cout << "Main proslije poziva funkcije uvecaj: " << endl;
- cout << "a: " << a << endl;
- cout << "b: " << b << endl;
- system("PAUSE");
- return 0;
- }
- /////
- #pragma warning (disable:4996)
- #include <iostream>
- using namespace std;
- int main()
- {
- int a = 15;
- int & refA = a;
- cout << "Vrijednost varijable a: " << a << endl;
- cout << "Vrijednost reference ref: " << refA << endl;
- cout << "---------------------------------" << endl;
- refA = 10;
- cout << "refA=10" << endl;
- cout << "-----------------------------" << endl;
- cout << "Vrijednost varijable a je: " << a << endl;
- cout << "Vrijednost reference ref je: " << refA << endl;
- cout << "-----------------------------------" << endl;
- a++;
- cout << "a++ " << endl;
- cout << "---------------------------------" << endl;
- cout << "Vrijednost varijable a je: " << a << endl;
- cout << "Vrijednost reference ref je: " << refA << endl;
- cout << "-----------------------------------" << endl;
- system("PAUSE");
- return 0;
- }
- /////
- #pragma warning (disable:4996)
- #include <iostream>
- using namespace std;
- void uvecaj(int & ref)
- {
- cout << "Unutar funkcije uvećaj: " << endl;
- ref++;
- cout << "ref++" << endl;
- cout << "adresa varijable ref: " << &ref << endl;
- cout << "Vrijednost varijable ref: " << ref << endl;
- cout << "-----------------------" << endl;
- }
- int main()
- {
- int a = 5;
- cout << "Main prije poziva funkcije uvecaj: " << endl;
- cout << "Adresa varijable a: " << &a << endl;
- cout << "Vrijednost varijable a: " << a << endl;
- cout << "-----------------------------" << endl;
- uvecaj(a);
- cout << "main poslije poziva funckije uvecaj: " << endl;
- cout << "adresa varijable a: " << &a << endl;
- cout << "vrijednost varijable a: " << a << endl;
- cout << "------------------------" << endl;
- system("PAUSE");
- return 0;
- }
- /////
- #pragma warning (disable:4996)
- #include <iostream>
- using namespace std;
- bool provjeri(int broj)
- {
- if (broj >= 10)
- return true;
- else
- return false;
- }
- int main()
- {
- int broj = 0;
- bool(*pFunkacija)(int) = nullptr;
- pFunkacija = &provjeri;
- cout << "Unesite neki broj: ";
- cin >> broj;
- bool odgovor = (*pFunkacija)(broj);
- if (odgovor == true)
- cout << "Broj je veci ili jednak 10!" << endl;
- else
- cout << "Broj je manje od 10!" << endl;
- system("PAUSE");
- return 0;
- }
- /////
- #pragma warning (disable:4996)
- #include <iostream>
- using namespace std;
- int saberi(int a, int b)
- {
- return a + b;
- }
- int main()
- {
- int a = 6;
- int b = 7;
- int(*pFunkcija)(int, int) = &saberi;
- if (pFunkcija == &saberi)
- cout << "Zbir brojeva je: " << (*pFunkcija)(a, b) << endl;
- else
- cout << "Greska pri pozivanju programa!" << endl;
- system("PAUSE");
- return 0;
- }
- /////
- #pragma warning (disable:4996)
- #include <iostream>
- using namespace std;
- int naKvadrat(int broj)
- {
- return broj*broj;
- }
- int naKub(int broj)
- {
- return broj*broj*broj;
- }
- void centralna(int broj, int(*pFunkcija)(int))
- {
- int rezultat = (*pFunkcija)(broj);
- cout << "Rezultat je: " << rezultat << endl;
- }
- int main()
- {
- int broj = 0;
- int(*pFunkcija)(int) = nullptr;
- cout << "Unesite neki broj: ";
- cin >> broj;
- if (broj < 10)
- pFunkcija = &naKub;
- else
- pFunkcija = &naKvadrat;
- centralna(broj, pFunkcija);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment