c program to swap two numbers using third variable

>> Monday, October 31, 2011

Hello! This program is very important as it is mostly taught and asked in external, vivas and some time in
campus recruitment exams also. We are Swapping the value of variable 'a' and 'b' by using a third variable 'temp'. Lets look on this program that how it is done.



#include<stdio.h> #include<conio.h>
int main() {     int a,b,temp;    printf("enter two values\n");    printf("\na = ");    scanf("%d",&a);    printf("\nb = ");    scanf("%d",&b);    temp=a;    a=b;    b=temp;    printf("\na = %d\tb = %d ", a, b);    getch(); }

Output :



 C program to swap two numbers using third variable
C program to swap two number using third varaible 

0 comments:

Post a Comment

About This Blog

This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.

Share and Save