Friday, August 16, 2019

WAP to swap two numbers using third variable.

//Program

#include<stdio.h>
void main()
{
      int a,b,temp;
      clrscr();
      printf("Enter any two numbers:");
      scanf("%d %d",&a,&b);
      prinft("Before swapping of numbers: a=%d and b=%d",a,b);
      temp=a;
      a=b;
      b=temp;
      printf("After swapping of numbers: a=%d and b=%d",a,b);
      getch();
}


Sample Input/Output:

Enter any two numbers:10
20
Before swapping of numbers a=10 and b=20
After swapping of numbers a=20 and b=10

No comments:

Post a Comment

Write a program to find gcd of two numbers using recursion.

About:  The process in which a function calls itself is called recursion and the corresponding function is called as recursive function. ...