Computer Science, asked by ArmanMishra6666, 1 year ago

write a program to swap two numbers with the help of third variable​

Answers

Answered by AnonymousKSB
1

Answer:

C Using A Third Variable

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,temp;

clrscr();

printf("\n Type any two numbers to swap:\n ");

printf("\n A = ");

scanf("%d",&a);

printf("\n B = ");

scanf("%d",&b);

printf("\n Numbers before swapping \n");

printf("\n A = %d \t B = %d",a,b);

temp=a;

a=b;

b=temp;

printf("\n\n Numbers after swapping\n");

printf("\n A = %d \t B = %d",a,b);

getch();

}

Answered by parwatipanicker
0

Answer:

hey dude heres ur answer using C++

Explanation:

 #include<iostream.h>

      #include<conio.h>

      void main()

      {

             int a,b,temp;

             clrscr();

             

             cout<<"\nEnter value of A : ";  

             cin>>a;

             cout<<"\nEnter value of B : ";  

             cin>>b;

             cout<<"\n\nValues before swapping :";

             cout<<"\nA : "<<a;

             cout<<"\nB : "<<b;

             temp = a;

             a = b;

             b = temp;

             

             cout<<"\n\nValues after  swapping :";

             cout<<"\nA : "<<a;

             cout<<"\nB : "<<b;

             getch();

      }

      HOPE U GOT IT

TRULY SIMPLEST WAY

MARK ME AS BRAINLIEST

Similar questions