adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

C program for swapping 2 numbers with and without temp variables

C program for swapping 2 numbers with and without temp variables

#include<stdio.h>
#include<conio.h>
 void main()
  {
  int a,b;
   clrscr();
  printf("Enter two nos.:-");
  scanf("%d%d",&a,&b);
  printf("Before swapping value of a=%d, & value of b=%d\n",a,b);
  a=a+b;
  b=a-b;
  a=a-b;
  printf("After swapping value of a=%d, & value of b=%d",a,b);
  getch();
  }

Output:              

Post a Comment

0 Comments