Practice Problems
Practice Problems
1.
#include <stdio.h>
main()
int a, b;
int c = 5;
int *p;
a = 4 * (c + 5) ;
p = &c;
b = 4 * (*p + 5) ;
2.
#include <stdio.h>
main()
int x, y;
int *ptr;
x = 10 ;
ptr = &x ;
y = *ptr ;
*ptr = 25;
3.
#include <stdio.h>
main()
4. Call by value:
#include <stdio.h>
main()
int a, b;
a = 5 ; b = 20 ;
swap (a, b) ;
printf (“\n a = %d, b = %d”, a, b);
int t ;
t=x;
x=y;
y=t;
5. Call by reference:
#include <stdio.h>
main()
int a, b;
a = 5 ; b = 20 ;
int t ;
t = *x ;
*x = *y ;
*y = t ;
}
Put smallest in x
Swap y, z if necessary