In the previous blog we saw  how to find the ASCII value of the character .Now, we will see how to swap two numbers using a variable.

Basic Data Type:- int, char, float, double

int Datatype:-Its an integer datatype .Its of 2 bytes .Its range is −32,768 to 32,767.

char Datatype:-Its an character datatype. Its of  1 byte. Its range is -128 to 127 .

float Datatype:-Its for floating point numbers. Its of  4 byte.

double Datatype :-Its for large floating point numbers .Its of 8 byte

To swap two numbers using a variable :-

#include <stdio.h>
int main()
{
    int number1,number2,temp;
    printf("Enter two numbers ");
    scanf("%d %d",&number1,&number2);
    printf("The values before  swapping is %d %d\n",number1,number2);
    temp=number1;
   number1=number2;
   number2=temp;
   printf("The values after swapping is %d %d",number1,number2);
}

Algorithm:-
1.Start 
2.Declare 3 variables of type int as number1,number2,temp
3.Use a print statement to display enter two numbers 
4.Use a scanf and use the format specifier "%d"  to get the input of two numbers .
Explanation:-We use two format specifiers "%d" "%d" since we have to input variables
5.Store the number1 variable in a temp variable .
6.Now,store the number2 value in number1 variable 
7.Now store the value of temp variable (i.e., which has the number1 variable before swapping) in number2 variable .
8.Finally print the number1 and number2 variable .
9.Stop 

Screenshot:-
1.Program Screenshot:-



2.Code Screenshot:-




In next blog we will see how to check if two numbers are equal or not.