Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ZADANIE 1
- #include <iostream>
- using namespace std;
- int a = 15;
- int main(){
- cout << "wartosc przypisana do zmiennej: " << a << endl;
- cout << "adres w pamieci tej zmiennej: " << (intptr_t)&a << endl;
- }
- ZADANIE 2
- #include <iostream>
- using namespace std;
- int b = 20;
- int *a = &b;
- int main(){
- cout << "wartosc b: " << b << endl;
- cout << "adres b: " << (intptr_t)a << endl;
- cout << "adres wskaznika a: " << (intptr_t)&a << endl;
- cout << "wartosc wskaznika a: " << *a << endl;
- }
- ZADANIE 3
- #include <iostream>
- using namespace std;
- int a = 14;
- float b = 6.7;
- char c = 'x';
- int *w_a = &a;
- float *w_b = &b;
- char *w_c = &c;
- int main(){
- cout << "a: " << a << endl;
- cout << "b: " << b << endl;
- cout << "c: " << c << endl;
- cout << "adres a: " << (intptr_t)&a << endl;
- cout << "adres b: " << (intptr_t)&b << endl;
- cout << "adres c: " << (intptr_t)&c << endl;
- cout << "wartosc adresu a: " << *w_a << endl;
- cout << "wartosc adresu b: " << *w_b << endl;
- cout << "wartosc adresu c: " << *w_c << endl;
- }
- ZADANIE 4
- #include <iostream>
- using namespace std;
- int a = 6;
- int b = 8;
- int *w_a = &a;
- int *w_b = &b;
- int main(){
- cout << "suma: " << *w_a + *w_b << endl;
- }
- ZADANIE 5
- #include <iostream>
- using namespace std;
- int a = 6;
- int b = 8;
- int *w_a = &a;
- int *w_b = &b;
- int main(){
- cout << "iloczyn: " << *w_a * *w_b << endl;
- }
- ZADANIE 6
- #include <iostream>
- using namespace std;
- int suma(int *a, int *b);
- int a = 6;
- int b = 8;
- int *w_a = &a;
- int *w_b = &b;
- int main(){
- cout << "suma wynosi: " << suma(w_a, w_b)<< endl;
- }
- int suma(int *a, int *b){
- return *a + *b;
- }
- ZADANIE 7
- #include <iostream>
- #include <math.h>
- using namespace std;
- float pole(int *r);
- int r = 8;
- int *w_r = &r;
- int main(){
- cout << "pole kola wynosi: " << pole(w_r)<< endl;
- }
- float pole(int *r){
- return *r * *r * M_PI;
- }
- ZADANIE 8
- #include <iostream>
- using namespace std;
- int a = 45;
- int b = 44;
- int *w_a = &a;
- int *w_b = &b;
- int main(){
- if (*w_a > *w_b) cout << "Liczba 45 jest wieksza od 44" << endl;
- else cout << "Liczba 44 jest wieksza od 45" << endl;
- }
- ZADANIE 9
- #include <iostream>
- using namespace std;
- int silnia(int *w_a);
- int a = 6;
- int *w_a = &a;
- int main(){
- cout << "Silnia z 6 wynosi: " << silnia(w_a) << endl;
- }
- int silnia(int *w_a){
- int b = 1;
- for (int i = 1; i < *w_a+1; i++) b*=i;
- return b;
- }
- ZADANIE 10
- #include <iostream>
- using namespace std;
- int suma(int *w_a);
- int a[] = {8, 6, 2, 6};
- int *w_a = a;
- int main(){
- cout << "Suma wartosci elementow z tablicy wynosi: " << suma(w_a) << endl;
- }
- int suma(int *w_a){
- int b = 0;
- for (int i = 0; i < 4; i++) b+=*(w_a+i);
- return b;
- }
Advertisement
Add Comment
Please, Sign In to add comment