Answer to Question #291368 in C for Pacan

Question #291368

As a safety precaution banks provide a feature that during any ATM transaction if someone comes and attacks, then the customer can enter the ATM pin in reverse order. This sends a message to the nearest police station. However if the reversed pin is the same as he original pin then no alarm is created. The bank needs a software application that checks that a user chooses an ATM pin whose reverse is not the same number. A software need to be developed with following requirements using while loop.

a. Read the pin number

b. Calculate the reverse the pin number

c. if the reversed pin is same as original pin then inform the user that this is an invalid pin number


1
Expert's answer
2022-01-27T12:34:56-0500
#include <stdio.h>
#include <stdlib.h>


int main(){
	int PIN;
	//a. Read the pin number
	printf("Enter PIN: ");
	scanf("%d",&PIN);
	int curentPIN=PIN;
	//b. Calculate the reverse the pin number
	int reversedPIN=0;
	int remainder;
	while(curentPIN != 0) {
		remainder = curentPIN%10;
		reversedPIN = reversedPIN*10 + remainder;
		curentPIN /= 10;
	}
	//c. if the reversed pin is same as original pin then inform the user that this is an invalid pin number
	if(reversedPIN==PIN){
		printf("\nThis is an invalid PIN number.\n");
	}else{
		printf("\nThis is VALID PIN number.\n");
	}


	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