4
Contributors
5
Replies
27
Views
3 Years
Discussion Span
Last Post by Learner010
0

What do you have so far? Do you know what a pointer is? We only help people that show effort. If you dont show your code you dont get code.

0

yes i now pointer check this code but this swap only two numbers i have to do input 5 numbers...

#include <stdio.h>

int main()
{
   int x, y, *a, *b, temp;

   printf("Enter the value of x and y\n");
   scanf("%d%d", &x, &y);

   printf("Before Swapping\nx = %d\ny = %d\n", x, y);

   a = &x;
   b = &y;

   temp = *b;
   *b = *a;
   *a = temp;

   printf("After Swapping\nx = %d\ny = %d\n", x, y);

   return 0;
}
0

if you can swipe two numbers than you can swipe as many as you want with a loop, you just need to figure out how many swipes you need to make and which values/variables will be swipe each time

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.