/* Using C */
#include<stdio.h>
int main(){
int a, b, x;
scanf("%d", &a);
printf("Value of B: ");
scanf("%d", &b);
x = a;
a = b;
b = x;
printf("\nValue after swap:\n");
printf("Value of A: %d\n", a);
printf("Value of A: %d", b);
return 0;
}
/* Using C++ */
#include<iostream>
using namespace std;
int main(){
int a, b, x;
cout << "Value of A: ";
cin >> a;
cout << "Value of B: ";
cin >> b;
x = a;
a = b;
b = x;
cout << endl << "Value after swap: " << endl;
cout << "Value of A: " << a << endl;
cout << "Value of B: " << b;
return 0;
}
No comments:
Post a Comment