Question: 5 . a ) The following program is used to swap the contents of two pointer variables of integer type, but the program has some

5. a) The following program is used to swap the contents of two pointer variables of integer type, but the program has some errors. Correct the program to get the specified operation. Assume, if the values of a and b integer type pointer variables are 10 and 20 respectively before swapping, then the values of a and b are 20 and 10 respectively after swapping. 4.03 #include #include int main(){ int *a,*b, temp; a=(int*) malloc(sizeof(int)); b=(int*) malloc(sizeof(int)); scanf(%d%d, &a, &b); printf(%d %d
, a, b); temp=a; a=b; b=temp; printf(%d %d
, a, b); free(a); free(b); return 0; }4.0 b) Find output for the following program #include void change(int *x); int main(){ int a=10; printf(%d
, a); change(&a); printf(%d
, a); return 0; } void change(int *x){*x=*x*11; ++*x; return; } OR #include void func( int B[], int n); int main(){ int A[5]={10,20,30,40,50}; int i; for(i=0; i<5; i++) printf(%d , A[i]); func(A,5); printf(
); for(i=0; i<5; i++) printf(%d , A[i]); return 0; } void func( int B[], int n){ int i; for(i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!