Answer to Question #199305 in C for Prasanna

Question #199305

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


1
Expert's answer
2021-05-27T06:24:47-0400
#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;
}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS