Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Write C Program Prompts User Enter Series Integers Represent Coded Message Given Decoder P Q35570522

Write a C program that prompts the user to enter a series ofintegers that represent a coded message. I have given you thedecoder program so that you can see how it is written using arraynotation. Your assignment is to convert the code to a program thatuses only pointers and pointermath.

Your program must use pointernotation and pointer math (i.e. no arrayindex notation other than in the declaration section, no arrays ofpointers and no pointer offsets).

The dialog with the user might look like:


Enter string digits to decode:

109 138 145 145 148 81 69 142 153 76 152 69 146 138 7010

Enter the secret offset integer: 37

Decoded:

Hello, it’s me!


Note: The bold text representsthe “user input” from your program and is shown for clarity onlyhere. It is not required that your output be in this color. (Do noteven attempt to try!). Also note that what the user types in isindicated by the bolded black text above. Again, for clarity only.(The text will limited to an 80 character message. To test, copyand paste the entire line of digits above).

Below is a sample which provides a solution to the programusing “array” notation. You should use it as a guide and justmodify the code to use pointer notation.Note: An arrow line comment (< —-) can be found on thecode that needs to be removed and replaced by pointernotation.
SAMPLE

HINT: decoder program using arrays

#include <stdio.h>

void safer_gets(char [], int);
int main(){int i, x, y;char c;int v[81]={0}; // stores the coded string in number formchar t[81]; // stores the string that was coded
// user enters a string to be decoded:printf(“nEnter all the string digits to decode:n”);i=0;do{scanf(“%i”, &v[i]); //<————***if(v[i] == 10) break; //<————***i++; //<————***}while(i < 81); // end while //<————***// now enter an offset number:printf(“Enter the secret offset integer: “);scanf(“%i”, &x);while(c = getchar() != ‘n’);// now decode and convert to stringi = 0;while(v[i] != 10) //<————***{y = v[i]; //<————***t[i] = y – x; //<————***i++; //<————***}// end while loopt[i] = ”; //<————***
printf(“nn”);printf(“n decoded: n”);i = 0;while(t[i] != ”) //<————***{printf(“%c”, t[i]); //<————***i++; //<————***}// end whileprintf(“nn”);return 0;}// end main/*sample runs:
Enter string digits to decode:109 138 145 145 148 81 69 142 153 76 152 69 146 138 7010Enter the secret offset integer: 37

decoded:Hello, it’s me!
Press any key to continue . . .

Enter string digits to decode:84 113 133 44 115 123 123 112 44 120 123 123 119 117 122 51 5644 131 116 109 128 111 116 109 44 115 123 128 44 111 123 123 119117 122 51 75 10Enter the secret offset integer: 12

decoded:Hey good lookin’, whatcha got cookin’?
Press any key to continue . . .
*/

Leave a Reply

Your email address will not be published. Required fields are marked *