luluinstalock

zad 3 kolos 2016

Feb 11th, 2016
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. int m=1, p=2;
  3. void fun1(int m){
  4.     int x;
  5.     x=m+p;
  6.     printf("F1: m=%d, p=%d, x=%d \n", m, p, x);
  7. }
  8. int fun2(int x){
  9.     int p;
  10.     p=2*x-m;
  11.     printf("F2: m=%d, p=%d, x=%d \n", m, p, x);
  12.     return p;
  13. }
  14. int fun3(void){
  15.     static int val = 5;
  16.     return ++val;
  17. }
  18. int fun4(int *m){
  19.     int x = *m;
  20.     return ++(*m) + x;
  21. }
  22. int main(){
  23.     int m=3, x=4;
  24.     fun1(m);
  25.     printf("M1: m=%d, p=%d, x=%d \n", m, p, x);
  26.     m = fun2(x);
  27.     printf("M2: m=%d, p=%d, x=%d \n", m, p, x);
  28.     x = fun3();
  29.     printf("M3: m=%d, p=%d, x=%d \n", m, p, x);
  30.     p=fun3();
  31.     x=fun4(&m);
  32.     printf("M4: m=%d, p=%d, x=%d \n", m, p, x);
  33.     return 0;
  34. }
Add Comment
Please, Sign In to add comment