Design a C program to exchange the keys. The Two friends Bob and Jim met in a bank and discussed about their secret code. They decided to exchange their passwords for further transactions. Password of Bob is "Apple" and Jim is Orange". Print the password of Jim and Bob.
Input :
Apple Orange
Output :
Orange Apple
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char password1[30];
char password2[30];
scanf("%s",password1);
scanf("%s",password2);
// exchange the keys
char tempPassword[30];
strcpy(tempPassword,password1);
strcpy(password1,password2);
strcpy(password2,tempPassword);
printf("%s %s\n",password1,password2);
getchar();
getchar();
return 0;
}
Comments
Leave a comment