C Program to Swap Two Numbers | ZenTek ZenTek: C Program to Swap Two Numbers
Contact Us:

If You Have Any Problem, Wanna Help, Wanna Write Guest Post, Find Any Error Or Want To Give Us Feedback, Just Feel Free To Contact Us. We Will Reply You Soon.

Name: *

Email: *

Message: *


LiveZilla Live Help

C Program to Swap Two Numbers

This program asks user to enter two numbers and this program will swap the value of these two numbers.

Source Code to Swap Two Numbers

#include <stdio.h>
int main(){
      float a, b, temp;
      printf("Enter value of a: ");
      printf("Enter value of b: ");
      temp = a;    /* Value of a is stored in variable temp */
      a = b;       /* Value of b is stored in variable a */
      b = temp;    /* Value of temp(which contains initial value of a) is stored in variable b*/
      printf("\nAfter swapping, value of a = %.2f\n", a);
      printf("After swapping, value of b = %.2f", b);
      return 0;


Enter value of a: 1.20
Enter value of b: 2.45

After swapping, value of a = 2.45
After swapping, value of b = 1.2

Like the Post? Share with your Friends:-

Team SB
Admin: Akash



Contact Us


Email *

Message *


About Me

Hello Guys

I am an IT(Information Technology) Student design this blog for your Preference I always enjoyed technical things as a kid

now here i am sharing my knowledge about Tips and Tricks In Internet PC Windows Free Recharges and Other Cool Stuffs Too

So enjoy it


Widget by : ZenTek
Widget by : ZenTek
Copyright © . ZenTek. All Rights Reserved.
Designed by :-Way2themes