Swapping of two numbers.

                       Swapping of two number

This is program of swapping two number in c language.Swapping means two numbers will interchange their respective position.This is simple program in c language.Let's discuss the concept behind it.


https://programminghub1999.blogspot.com/2018/12/swapping-of-two-numbers.html



                        The following method has used in the given below program
  1. Take two input numbers from user(let x and y).
  2. Assign first number to other variable(let z) of same data type.
  3. Then assign the value of y into x.
  4. And assign the value of z into y.



                                     Swapping of two number

Let's first discuss about what is actual meaning of swapping.We will understand it with the help of an example.


       Let original position of two number is                   X  and   Y
    
        After swapping the position become                    Y   and   X


                                  Swapping program in c language


        This program has successfully run on turbo compiler.I personally use this editor for                writing my program.


#include<stdio.h>
#include<conio.h>
void main()
{
   clrscr(); 
   int x ,y,z;
   printf("Enter two numbers\n");
   scanf("%d %d",&x,&y);
   z=x;
   x=y;
   y=z;
  printf("After swapping the numbers are\n");
  printf("%d %d",x,y);
  getch();
}





Swapping of two numbers. Swapping of two numbers. Reviewed by Deepak kumar soni on December 29, 2018 Rating: 5

No comments:

Powered by Blogger.