Using C( not C++ or C#) I need help in constructing this function for a specific program without the use of arrays os strings for practice . Function Reqt - getBPswrd(int nPswrd , int nSeq) that determines the most suitable key from nPswrd for a given sequence nSeq. nSeq is an 8-digit +ve integer, while nPswrd  contains a maximum of 4 one-digit positive integers merged as one integer. A number from nPswrd is selected as the best key if it matches most of the digits in nSeq. Following are some desired test cases: Hypothetically - nSeq= 12134567 and nPswrd = 1234: The nPswrd are 1, 2, 3, and 4.                                           Pswrd Count 1 2 2 1 3 1 4 1 The best pswrd is:  1  Condtion - 2  If 2 or more different pswrd have the same count, the first key listed from the leftmost will be chosen as the best key. Example 3: Hypothetically : nSeq = 14325312 and nPswrd = 143: The pswrd are 1, 4, and 3. Pswrd Count 1 2 4 1 3 2 The best key is:  1 Last Condition There are also instances where 2 or more pswrd are just the same.  Example 4: Hypothetically : nSeq = 14325312 and nPswrd = 22: The keys are 2, and 2. Pswrd Count 2 2 2 2 The best pswrd is:  2 The int main of the practice problem is as follow int main () {    int nSeq, nPswrd, nB; nB = -1;   printf("Sequence: ");   scanf("%d", &nSeq);            printf("Pswrd: ");   scanf("%d", &nPswrd);            nB = getBPswrd(nSeq, nPswrd);   if (nB != -1)   {       printf("Best pswrd for the sequence: %d\n", nB);   }   else   {       printf("None of the pswrd are found in the sequence!\n");   } return 0; }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Using C( not C++ or C#) I need help in constructing this function for a specific program without the use of arrays os strings for practice .

Function Reqt - getBPswrd(int nPswrd , int nSeq) that determines the most suitable key from nPswrd for a given sequence nSeq.

nSeq is an 8-digit +ve integer, while nPswrd  contains a maximum of 4 one-digit positive integers merged as one integer. A number from nPswrd is selected as the best key if it matches most of the digits in nSeq.

Following are some desired test cases:

Hypothetically - nSeq= 12134567 and nPswrd = 1234:

The nPswrd are 1, 2, 3, and 4.                                          

Pswrd Count
1 2
2 1
3 1
4 1

The best pswrd is: 

Condtion - 2 

If 2 or more different pswrd have the same count, the first key listed from the leftmost will be chosen as the best key.

Example 3:

Hypothetically : nSeq = 14325312 and nPswrd = 143:

The pswrd are 1, 4, and 3.

Pswrd Count
1 2
4 1
3 2

The best key is:  1

Last Condition

There are also instances where 2 or more pswrd are just the same. 

Example 4:

Hypothetically : nSeq = 14325312 and nPswrd = 22:

The keys are 2, and 2.

Pswrd Count
2 2
2 2

The best pswrd is:  2

The int main of the practice problem is as follow

int main ()
{
   int nSeq, nPswrd, nB;
nB = -1;

  printf("Sequence: ");
  scanf("%d", &nSeq);
        
  printf("Pswrd: ");
  scanf("%d", &nPswrd);
        
  nB = getBPswrd(nSeq, nPswrd);
  if (nB != -1)
  {
      printf("Best pswrd for the sequence: %d\n", nB);
  }
  else
  {
      printf("None of the pswrd are found in the sequence!\n");
  }

return 0;
}

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY