Menu

Wednesday, 2 March 2016

C program to swap two numbers

#include <stdio.h>
#include<conio.h>

void main()
{
   int tval , a, b;

   printf("Enter the first value :\n");
   scanf("%d", &a);
   printf("Enter the second value :\n");
   scanf("%d", &b);

   printf("Before Swapping values are\n a = %d\n b= %d\n",a,b);

   tval = a;
   a    = b;
   b    = tval;

   printf("After Swapping\na = %d\nb = %d\n",a,b);

   getch();
}

No comments:

Post a Comment