1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
klasskru [66]
3 years ago
13

You are given a 5-letter word (for example, abcde). Write a C-Program which outputs all possible unique 5 letter permutations of

this word in a text file. There should be no repetition of letters in permutation (i.e. in our example, bacde is a valid permutation but bbcde is invalid. Use of library functions for generation of permutations is NOT allowed.
The text file containing the output should be named as q3out.txt. Each word of the output must be on a separate line in the text file. The 5-letter input word should be read by your program from the console. Provide comments in your code. Submit your C code, and the q3out.txt file for the following inputs:
(a) parba
(b) arbca
Computers and Technology
1 answer:
kari74 [83]3 years ago
4 0

Answer:

See attachment 1 for code

See attachment 2 for the output of permuting letters of parba

See attachment 3 for the output of permuting letters of arbca

Explanation:

The program was implemented in C

The program uses a recursive function letterpermutation and a swap function to successfully implement the requirement of this question.

The letterpermutation function is defined here

void letterpermutation(char *mystring, int index1, int index2) {  

This lets the program writes to a file

  FILE *fptr;

This opens the file in an appending mode

  fptr = fopen("q3out.txt","a");

int i;

This checks for unique strings.

if (index1 == index2) {

If found, this appends the string to the text file

   fprintf(fptr,"%s\n",mystring); }

If otherwise

else{  

This iterates through the string

for (i = index1; i <= index2; i++)   {

The swap function is called to swap the characters of the string

 swap((mystring+index1), (mystring+i));  

This calls the function, recursively

letterpermutation(mystring, index1+1, index2);  

This further swaps the characters of the string

swap((mystring+index1), (mystring+i));  

} } }  

The swap function begins here and what it literally does is that it swaps characters of the input string to create a new string

<em>void swap(char *ch1, char *ch2) {  </em>

<em> char temp;  </em>

<em> temp = *ch1;  *ch1 = *ch2;  *ch2 = temp; } </em>

The main function begins here

int main() {  

This declares and initializes the string

char mystring[] = "ABCd"; // The string here can be changed

This calls the function to permute the string

letterpermutation(mystring, 0, strlen(mystring)-1);  

return 0; }

Download txt
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> txt </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> txt </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> txt </span>
You might be interested in
Which statements accurately describe the Outlook interface? Check all that apply.
blagie [28]

Answer:

All are right except the 4th one.

1) Two main elements are items and folders.

2) The content pane contains a list of items to be viewed in the reading pane.

3) The ribbon contains a list of tabs and menu items.

5) The main Outlook menu has a ribbon tab with default commands.

6) File, Home, Send/Receive, Folder, and View are commands on the main ribbon tab.

Explanation:

Hope this helped Justine!

7 0
3 years ago
You have a large dataset that will print on several pages. You want to ensure that related records print on the same page with c
Mumz [18]

Answer:B

Explanation:

3 0
3 years ago
Identify the layout in which you will be able to view and edit the header and footer
sergiy2304 [10]
The answer is (c.) Print Layout

The print layout view is the default view in Microsoft Office Word upon opening the application. In a new document, to add a header and a footer, go to Insert Tab. Under the Header and Footer section, you have the option to add a header and a footer. There are built-in designs to choose from by just clicking on the drop down arrow.
6 0
3 years ago
A group consists of 10 kids and 2 adults. On a hike, they must form a line with an adult at the front and an adult at the back.
blsea [12.9K]

Answer:

b. 2.9!

Explanation:

There are is a mistake in the question.

Suppose the group consist of 10 kids and 2 adults, the number of ways in which they can form the line is:

= 2! 10!

= 2× 1× 10!

= 2.10!

But since that is not in the given option.

Let assume that the group consists of 9 kids and 2 adults, the number of ways in which they can form the line is:

No of ways the kids can be permutated =  9 ways

No of ways the adult can be permutated  = two ways.

Thus; the number of ways in which they can form the line = 2! 9!

= 2 × 1× 9!

= 2.9!

6 0
3 years ago
Identify measures to protect your computer against threats from human actions. You cannot access a file in a computer that belon
scZoUnD [109]

Answer:

Firewalls

Explanation:

A firewall is simply a network security system whose main duty is. to prevent unwanted access to. private network.

Firewalls is measures to protect your computer against threats from human actions.

It is also the one singular thing that prevents you from accessing the file on your friends system.

5 0
3 years ago
Other questions:
  • An enterprise system is a packaged software application that helps integrate various ___________ in a company.
    15·2 answers
  • Write a program that displays the following menu:
    8·1 answer
  • Machu Picchu is located in modern day _______<br><br>​
    14·2 answers
  • Write a Python 3 script in PyCharm that will simulate the game of "Rock, Paper, Scissors": Display a header and the simple rules
    8·1 answer
  • Drag the correct type of update to its definition.
    13·1 answer
  • Two threads try to acquire the same resource at the same time and both are blocked. Then, they continually change their states i
    14·1 answer
  • Complete the sentence.<br> A ___ number is composed of only zeros and ones.
    8·1 answer
  • You are network administrator for an Active Directory forest with a single domain. Then network has three sites with one domain
    12·1 answer
  • Examples of system software include operating systems like macos, Linux, Android and
    10·2 answers
  • How do I find unwanted programs on my computer?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!