Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//** Use C and use only use <stdio.h> **// The program requested in the previous

ID: 3638868 • Letter: #

Question

//** Use C and use only use <stdio.h> **//

The program requested in the previous problem assumes that a word has exactly seven letters. However, in reality, words in the ABRACADABRA language may have arbitrary length. Thus it would be nice to modify this program so that it can support words of arbitrary length. Therefore, you are requested to write a C program that creates by itself the abracadbra encoder program for any given word length. Your program should prompt the user for the desired word length, and then output a C code of the abracadbra encoder program for the specified length.
To see how one C program can output another C program, consider the following program, called herein write hello.c, that prints to the screen the famous .hello world!. program:

#include <stdio.h>
int main()
{
printf("#include <stdio.h> ");
printf("int main() ");
printf(" ");
printf(" printf("hello world! "); ");
printf(" return 0;n");
printf("}");
return 0;
}
Note:
Note that the fourth printf statement above contains the sequences " and \. The reason
is that inside a printf statement, the characters " and n have special meanings: the former
signifies the start and the end of the printf format string, while the latter modifies the meaning
of the character that follows. For example, is the new-line character, rather than the character
`n'. To .turn off. these special meanings, one should precede " and by the backslash .
Thus " just prints a " while \ just prints a . You might want to test those yourself.

The % character also has a special meaning inside the printf format string (what is its meaning?).
Thus, in order to print the % character itself, you should write %%. For example, check the
output of printf("Up to 50%% discount!")

To verify the correctness of the above program you should redirect its output to a file. For example, if the executable file is called write hello, you should invoke the program as follows:

/home/userXYZ/ECE15/Lab2> write hello > hello.c

If write hello.c is written correctly, then the above should create a file called hello.c.
The file hello.c can then be compiled to generate an executable file which, when run, should
print hello world! to the screen. It is recommended to actually try this!

You should test the correctness of the program write encoder.c, that you are writing in this problem, in the same way. For example:

/home/userXYZ/ECE15/Lab2> write encoder > mytest1.c

Make sure that the output is redirected to a _le with a .c suffix, so that it can be compiled
afterward. As you develop your code, you may want to create several such mytest.c programs.
Observe that when you follow the example above, the prompt “Enter the desired word
length:.”will be printed to the file mytest1.c and not to the screen. This implies two things.
First, you will have to type-in the desired word length, without being prompted for it. Second,
before you can compile the file mytest1.c you should manually delete the first line in this file.
You can avoid these complications, during most of the development, by leaving out from your
program the part that deals with prompting the user and reading the desired word length. You
could add this part when you are sure that the rest of your code is correct.

In this problem, you may assume that the user will enter a positive integer when prompted for
the desired word length. Moreover, even though words in the ABRACADABRA language can
have arbitrary length, you may assume that the user will not request a length greater than 200.

Here is a sample run of the write encoder.c program, assuming that the executable file is called write encoder. In this example, the user enters 100 as the desired word length.

/home/userXYZ/ECE15/Lab2> write encoder
Enter the desired word length: 100
#include <stdio.h>
int main()
{
char . . .
printf(" Enter key: ");
...
return 0;
}

Explanation / Answer

Hi, hope this will help u #include #include int main() { char abracadabra[] = {'a','b','c','d','e'}; char secret_key[] = {'f','g','h','i','j'}; char new_word[] = {"ggifj"}; char *pos; int i; for (i=0; i