Dynamically allocate memory for two integers. Swap their values. write your statement in C
#include <stdio.h> #include <stdlib.h> int main(){ // Dynamically allocate memory for two integers int *x = (int*)malloc(sizeof(int)); int *y = (int*)malloc(sizeof(int)); int temp; *x = 5; *y = 3; temp = *x; *x = *y; *y = temp; printf("*x = %d\n",*x); printf("*y = %d\n",*y); return 0; }
Get Answers For Free
Most questions answered within 1 hours.