Swapping of Two Numbers in C

Swapping of Two Numbers in C using Temporary variables:

Swapping of Two number program in C:
#include<stdio.h>
int main()
{
 int a;
 int b;
 int c;
 printf("Type value of A = ");
 scanf("%d",&a);
 printf("\nType value of B = ");
 scanf("%d",&b);
 c=a;
 a=b;
 b=c;
 printf("A = %d  \n",a);
 printf("B = %d",b);
 return 0;
}
Output:
Type value of A = 5
Type value of B = 2
A = 2
B = 5
Explanation:
  • Three integers values of a, b, c is declared.
  • The values of a, b are taken from keyboard given by the user.
  • Now the value of “a” stored in “c” and the value of “b” stored in “a” the value of “c” stored in “b”. And last Prints the value of “a” and “b”.
See also:
Share:

Our Services

Search This Blog

  • ()
Powered by Blogger.

Alphabet Pattern (or) Character Pattern21 Program in C

Write "C"  Program to print below Alphabet Pattern21 (or) Character Pattern21: To underst...

Blog Archive