Skip to main content

C program to swap to values using the Third Variable



#include<stdio.h>
/*#include<conio.h>*/
int main()
{
int a,b,c;
/*Accept the values for swapping*/
printf("Enter the two values:");
scanf("%d%d",&a,&b);
/*Print the values before swapping*/
printf("Values before swapping:%d and %d",a,b);
/*Logic for Swapping*/
c=a;       /*Here the value of a is stored in variable c*/
a=b;      /*Now the value of b is assigned to variable a*/
b=c;     /*Finally the value stored in c is assigned to b*/
/* Now, lets print the swapped values*/
printf("Values after swapping:%d and %d",a,b);
return 0;
}


The above Program is using three variables a,b and c. The two values that we enter will be stored in the variables a and b correspondingly. We use a third variable c as the temporary variable to store data temporarily or for some sort of time. Now when c=a is executed the value in a is stored temporarily in c, so that the value will not be lost. Then we execute the next line a=b, this will assign the value of b to a. Then the final line of logic, b=c; this will assign the value in temporary variable c to b, which was the previous value stored in a. 

Output

Enter two values:
20 30
Values before swapping: 20 and 30
Values after swapping: 30 and 20

Note: I have commented #include<conio.h> because it would be necessary if you guys need to insert the function getch(); For some Turbo C compiler it is required as to buffer the output to the monitor.

Comments

Popular posts from this blog

Maxon Cinema 4D Studio R13.058 full Keygen Cracked Version | Mediafire Torrent Download Link

Download Maxon CINEMA 4D Studio Full Version With Keygen -Everything You Need for High-End 3D 32 and 64 bit MAXON CINEMA 4D STUDIO R13.058 (x86/x64) CINEMA 4D Studio is the very best that MAXON has to offer for professional 3D artists. If you want to create advanced 3D graphics but need a helping hand to ensure you create jaw-dropping graphics quickly and easily, then this is the choice for you.                     All You Ever Wanted This is our top-of-the-line product. It not only contains everything the other CINEMA 4D versions offer - it goes far beyond. CINEMA 4D Studio has all the tools you need to tackle even the most complex project. Minimum System Requirements Windows XP, Vista or 7 running on Intel or AMD CPU with SSE2-Support; Mac OS X 10.5.8 or higher running on an Intel-based Mac; 1024 MB free RAM, DVD ROM drive. Standard DVD installation can take up to 4 GB of disk space. Software m...

Minitool Power Data Recovery 6.6 Activation Key

- Technician License: MSMCS3KFS58YUPUYVA3388SVC4PPC4P8 SS45A5MMPAXAU3CXKAA8U88A5CY3SVPU ASAAXUKCVM8UYXMSKVXSU55A5434UKP5 5S8P4UMC8544M8A5K88KAPC8W4CKK8PM 4SSXYAMWUM8SSASKYXSMSY35WCKX5PPK ASK4M3M4MAF3C3MXFWUWSV3MV4PKMCPY SSFF3PM835YK8UUVMPFW4SCSMC3YXAPY 5SXVFYMY8MF333SYKMY8KCPUP4AWYFPU CSVKKSKV45MM58M8MUKWA4KUKCA5AWP5 YS8C88KPFMKFK5P84WUAMSU3CC4U8AP4 CSY54KMVFMY8CU4AS5PPPUYP8CP3F8PM 5S3CMXM38AUKYPYUSWVVW3FPX4VUVCPM CS58YMKC3AVVU4KK8843WSYKKCY8M8P5 MSVKKSMUXMWVF5KU4AMM4AV8Y4A55WPU - Enterprise License: 33M5V84A3V44AMVUWVUFXKWXCCU3SUUC X3PFS54PM5SFCKP5W5YY4VXCS44YPWU3 K3KSKP434MWKASWYUK3PPXVP8CWS3PUX P3A3PM4U8VM4F4SKCCPP845FA48X5CUV U3Y5AK4335SXAYWPC3CA4MK834U8XYUX K3M8SXPS4MUXCAY5X4K4A5A5FCW3UFUS K35KC843YAW4UXFFFWMAX8V8FCYVCWUX K3FAW84CWV3UCY35K5YY4UY33CKSUXUX 83PCFMPXY5PVFKKY8KKFMAV45C4UP4UW 8388PU48AAWVAKCVA5FP4853ACSFVCU3 U3YVYU4SXM834AUXWVWAWV3434WPKSUC F3YSS5PMVAWWWSCYFKCFX85SPCP4WWUA 33MY5S4UXVUS45YCMY5UPKVY4CXV5MUV F3XFK445A55A48CWX4SWM3VSWCVYFPU...

serial keys of all softwares

Windows7 Professional Key 3YHKG-DVQ27-RYRBX-JMPVM-WG38T Windows-7 32-bit Serial Key Free MVBCQ-B3VPW-CT369-VM9TB-YFGBP AVIRA ANTIVIRUS SERIAL KEYS/PRODUCT KEYS FREE s/n: QAAU3-ZLRJS-PXVLR-HAL72-MRFZU NORTON ANTIVIRUS BETA SERIAL KEYS VH9VFRM8BBHKVH3DWV7RBBGJ  VJG24VBWRBHKVFWMMPHMBBJ4 PHOTOSHOP CS3 SERIAL KEYS FREE 100% Working 1325-1114-5477-3347-7571-7576 1330-1302-4838-3919-1811-3226 1330-1811-8459-8582-7342-7197 1330-1637-7269-9714-1829-1556 1330-1725-5491-6912-9296-1410 1330-1517-7045-7767-4478-1135 1330-1307-7591-0768-4856-0992 1330-1587-8723-2610-2647-0244 1330-1254-7247-1076-1307-2010 1330-1628-1239-1139-9402-3011 1330-1591-8350-4925-6049-9747 1330-1386-9562-7447-8387-6821 1330-1589-4157-0213-2262-7177 1330-1035-1051-8428-7106-0807 1330-1573-9033-1873-5059-5246 1330-1728-0465-5816-2513-3488 Advanced SystemCare Pro Serials ##SHOW MORE## “8933F-8E178-0FE81-C8BAA” DFF7A-8204E-69ADE-0D5AA DFF7A-8204E-69ADE-0D5AA Link For AdvancedSystemCare5:http:/...