Hello. I am a beginner. I have searched the past threads, but I haven't found any help. My assignment says to write a function to swap 2 values using pointers. Write a main function that inputs 2 numbers. Have it call the swap function if the numbers are NOT in descending order - include a loop to allow the user to enter 3 sets of numbers.
I have been working on this for hours. The deeper I get, the more I confuse myself.
Here's the code that I have. It is nowhere close to complete.
Can someone please give me some help? Any help is appreciated!
#include<stdio.h>
int main()
{
void swap(int *, int *); //prototype with a pointer parameter
int count;
int num1, num2;
int swapvalue;
int holdScreen; // holdscreen is used to keep the ouput window open
for (count = 1; count <4; count++) //begin loop
printf("Enter the first number -> ");
scanf("%d", &num1);
printf("Enter the second number -> ");
scanf("%d", &num2);
if (num1 < num2 )
{
swap(&num1, &num2); //Function Calling Statement
}
else
printf("No swap needed")
printf("The address that will be passed for num1 is %d\n\n", &num1);
printf("The address that will be passed for num2 is %d\n\n", &num2);
count ++
scanf("%d", &holdScreen);
return 0;
}
void swap(int *num, *num2) //Function Header Line
{
}