1. Write a function to swap two double values with pointers asparameters.
2. Write a main function which declare two double variables withinitial values: x=1.2 and y=4.5, print them out, then call swapfunction to switch x and y values, then print them out too.
C programming language
Answer
#include <stdio.h>void swap(double *n1, double *n2) { double temp = *n1; *n1 = *n2; *n2 = temp;}int main() { double x=1.2, y=4.5; printf(“Before swap, x=%lf and y=%lfn”, x, y); swap(&x, &y); printf(“After swap,
OR
OR