Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Wednesday, 3 January 2018

Program to swap two numbers using third variable

#include<stdio.h>#include<conio.h>int main(){    int a,b,c;    clrscr();    printf("Enter first number:");              // input from user    scanf("%d",&a);    printf("Enter second number:");    scanf("%d",&b);    printf("Before swapping:%d %d\n",a,b);    c = a;    a = b;                                      // swapping using three variables    b = c;    printf("After swapping:%d %d\n",a,b);    getch();}

No comments:

Post a Comment