Wednesday, September 23, 2020

Swap Two Numbers in C

 A simple C program to ask the user to give two numbers and then the program will swap the arrangement of the two numbers.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking and Arduino Project development at a very affordable price.


Program Listing

/* swap.c
   Jake Rodriguez Pomperada,MAED-IT,MIT
   September 23,2 2020
   www.jakerpomperada.com
   www.jakerpomperada.blogspot.com
   jakerpomperada@gmail.com
*/

#include <stdio.h>

int main() 
 {
   int a=0,b=0, temp=0;
   system("COLOR F0");
   printf("\n\n");
   printf("\tSwap Two Numbers in C");
   printf("\n\n");
   printf("\tGive First Value  : ");
   scanf("%d", &a);
   printf("\n");
   printf("\tGive Second Value : ");
   scanf("%d", &b);
   printf("\n\n");
   printf("\tBefore Swapping");
   printf("\n\n");
   printf("\tA = %d and B = %d",a,b);
   
   // Swapping of values here
   temp = a;
   a = b;
   b = temp;
   
   printf("\n\n\n");
   printf("\tAfter Swapping");
   printf("\n\n");
   printf("\tA = %d and B = %d",a,b);
      
   printf("\n\n\n");
   printf("\tEND OF PROGRAM");
   printf("\n\n");
}

No comments:

Post a Comment