Question

C Programming. How to compare two sets of intergers which are inputted by the user? "cannot share any digit at the same place with your current PIN". Cant use any relational or logical operators.

Example Execution #1 ('3' digit in the hundreds place is common to both PINs):

Enter your current PIN: 12345

Enter your new PIN: 98310

Total number of invalid digits: 1

Problem: Your preferred banking institution is requiring that you change your five digit PIN in the name of security. One requirement of your new PIN is that it cannot share any digit at the same place with your current PIN. Given both the current and new PIN print the total number of invalid digits. Both PIN values will be in the range [00000, 99999] Example Execution #1 (3 digit in the hundreds place is common to both PINs): Enter your current PIN: 12345 Enter your new PIN: 98310 Total number of invalid digits:1 Example Execution #5: Enter your current PIN: 13433 Example Execution #2: Enter your current PIN: 01010 Enter your new PIN: 10101 Enter your new PIN: 43133 Total number of invalid digits: 3 Example Execution #6: Enter your current PIN: 19183 Total number of invalid digits: 0 Example Execution #3: Enter your current PIN 12345 Enter your new PIN: 22345 Enter your new PIN: 28273 Total number of invalid digits:1 Example Execution #7: Enter your current PIN: 12244 Total number of invalid digits: 4 Example Execution #4: Enter your current PIN: 99999 Enter your new PIN: 00000 Enter your new PIN: 44241 Total number of invalid digits: 0 Total number of invalid digits: 2 Please review the ASSIGNMENT REQUIREMENTS for this program. The use of selection, including logical and relational operators, is prohibited. The on pages techniques necessary to solve this problem are similar to the examples found e notes packet.

Example Execution #6:

Enter your current PIN: 19183

Enter your new PIN: 28273

Total number of invalid digits: 1

Dont use any relational or logical operators, dont use user defined functions (diff etc), dont use arrays. Refer to example below to solve.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>

int main() {
int oldPin;
int newPin;
int invalid=0;
printf("Enter your current pin:\n");
scanf("%d",&oldPin);
printf("Enter your new pin:\n ");
scanf("%d",&newPin);
while(oldPin>0 || newPin>0 )
{
if(oldPin%10==newPin%10)
{
invalid++;
}
oldPin=oldPin/10;
newPin=newPin/10;
}
printf("Total number of invalid digits are %d",invalid);
}

Add a comment
Know the answer?
Add Answer to:
C Programming. How to compare two sets of intergers which are inputted by the user? "cannot...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Given java code is below, please use it! import java.util.Scanner; public class LA2a {      ...

    Given java code is below, please use it! import java.util.Scanner; public class LA2a {       /**    * Number of digits in a valid value sequence    */    public static final int SEQ_DIGITS = 10;       /**    * Error for an invalid sequence    * (not correct number of characters    * or not made only of digits)    */    public static final String ERR_SEQ = "Invalid sequence";       /**    * Error for...

  • Validating a PIN

    1.      Validating a PINBanks use a Personal Identification Number to uniquely identify each customer. Let us assume that our bank has a specified range of acceptable values for each digit in its customer’s 5-digit PINs. The table shown below contains the acceptable ranges, where the digits are numbered from left to right in the PIN. Then we can see that the PIN 52413 is valid. But the PIN 43534 is invalid because the first digit is out of range. Similarly,...

  • Validating a PIN

    1.      Validating a PINBanks use a Personal Identification Number to uniquely identify each customer. Let us assume that our bank has a specified range of acceptable values for each digit in its customer’s 5-digit PINs. The table shown below contains the acceptable ranges, where the digits are numbered from left to right in the PIN. Then we can see that the PIN 52413 is valid. But the PIN 43534 is invalid because the first digit is out of range. Similarly,...

  • Part 1 – Data Encryption Data Encryption is the process of transforming data, using a cipher,...

    Part 1 – Data Encryption Data Encryption is the process of transforming data, using a cipher, to make it unreadable to anyone except those possessing special knowledge. In this problem you will implement a simple encryption technique on data that comprises of non-negative integers that have at least six digits with no leading zeroes. In order to encrypt the number the following functions are to be implemented: void input(int *num); int add4(int num); int shift(int num); void printOutput(int encryptNum, int...

  • Q10 Total salads 2 Points A restaurant has nine different salad add-ons. In how many different...

    Q10 Total salads 2 Points A restaurant has nine different salad add-ons. In how many different possible salads can you order (and yes, you can order a salad with just lettuce)? Enter your answer here Q11 Pin number 3 Points For his work computer, Donald has to create a 4-digit pin. It must be 4 digits long, can only use the digits 1.9, and cannot repeat any digits. Donald is curious how many of these pins are possible and does...

  • Digit to WordsWrite a C program that asks the user for a two-digit number, then prints...

    Digit to WordsWrite a C program that asks the user for a two-digit number, then prints the English wordfor the number. Your program should loop until the user wants to quit.Example:Enter a two-digit number: 45You entered the number forty-five.Hint: Break the number into two digits. Use one switch statement to print the word for the firstdigit (“twenty,” “thirty,” and so forth). Use a second switch statement to print the word for thesecond digit. Don’t forget that the numbers between 11...

  • (use only variables, expression, conditional statement and loop of c programming) ***C programming** int sum_of_cubes(int n)...

    (use only variables, expression, conditional statement and loop of c programming) ***C programming** int sum_of_cubes(int n) { } int quadrant(int x, int y) { } int num_occurrences_of_digit(long num, int digit) { return 0; } 3.1 int sum_of_cubes(int n) This function should return the sum of the cubes of the first n integers. For example, if n is 4, it should return 13 +23+ 39 +4°. There is a simple formula for the result: 3x = ((n + 1)) = +...

  • Programming Concepts CS 225 for C++ To make telephone numbers easier to remember, some companies use...

    Programming Concepts CS 225 for C++ To make telephone numbers easier to remember, some companies use digits and letters (or only letters) to show their telephone number. In some cases, to make a telephone number meaningful, companies might use more than seven digits and letters. Here are some examples: Phone Number in Display Note Actual Phone Number GET LOAN - 438-5626 CALL HOME More than seven digits/letters used for ease of remembrance. 225-5466 111 GOLD - 111-4653 Glass4u - 452-7748...

  • For programming C language This problem will be briefly discussed in Lab2 and the TĀ will...

    For programming C language This problem will be briefly discussed in Lab2 and the TĀ will give you hints to solve it. However, the TĀ will not write the code. This code is a bit complicated, so try to understand the process from the TA so that you can continue working on it at home. Reverse the Number Write a program that takes a 5-digit number as input and print the reverse of the number. Sample Input/Output: Enter a five...

  • Phone Number Problem (Use Object-Oriented Programming Style. Otherwise there will be no credit) Write a C++ program tha...

    Phone Number Problem (Use Object-Oriented Programming Style. Otherwise there will be no credit) Write a C++ program that can convert any 7-digit telephone number into corresponding words where the equivalence of each digit and its corresponding characters is defined in the telephone keypad, which is shown in the following table: ABC 4 1 JKL MNO 8 TUV WXYZ In the keypad, there is no equivalence for digit 1 and 0, but in reality, the phone number might contain those two...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT