Complete the Swap() method in C language, main.c to exchange the values of the num field of two Number struct objects, num1 and num2. Thank you so much in advance Hint: Refer to the given Number struct to see the num data member. Ex: If num1 is 19 and num2 is 178, calling Swap(num1, num2) will swap the values so that num1 becomes 178 and num2 becomes 19.
Complete the Swap() method in C language, main.c to exchange the values of the num field of two Number struct objects, num1 and num2.
Thank you so much in advance
Hint: Refer to the given Number struct to see the num data member.
Ex: If num1 is 19 and num2 is 178, calling Swap(num1, num2) will swap the values so that num1 becomes 178 and num2 becomes 19.
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
#include <stdio.h>
#include <stdlib.h>
typedef struct Number_struct {
int num;
} Number;
void Swap(Number* numPtr1, Number* numPtr2) {
/* Your code goes here */
}
int main(void) {
Number* num1 = NULL;
Number* num2 = NULL;
num1 = (Number*)malloc(sizeof(Number));
num2 = (Number*)malloc(sizeof(Number));
int int1;
int int2;
scanf("%d", &int1);
scanf("%d", &int2);
Thank you so much but i forgot to put this how i would fit in into this.
num1->num = int1;
num2->num = int2;
Swap(num1, num2);
printf("num1 = %d, num2 = %d\n", num1->num, num2->num);
return 0;
}
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)