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

C Programming In your home directory, create EncDec; Write 1 program that perfor

ID: 3664588 • Letter: C

Question

C Programming

In your home directory, create EncDec;

Write 1 program that performs the following tasks

   b) Encode & decode

       b1) shift for lowercase & digits

       b2) rotate for lowercase & digits (can be separate)

       b3) the replacement/substitution mapping

See below for a more in-depth explanation

- read lines of input until end-of-file

- store the text in a string

- you may assume size 100 will fit the full line

- convert all of the letters to lower case

Something new so we can do a few things in one program - on the same input

char orig[100], secret[100], show[100]; ...

printf(" Orig   is #%s# ", orig);

fun( orig, secret);

printf(" Secret is #%s# ", secret);

unfun( secret, show );

printf(" Show   is #%s# ", show);

...

---------------------------------------------------------------

---------------------------------------------------------------

Similar code sections for (b1)(b2)(b3); for example

printf(" Orig   is #%s# ", orig);

encb1( orig, secret, amt);

printf(" Secret is #%s# ", secret);

decb1( secret, show, amt );

printf(" Show   is #%s# ", show);

printf(" Orig   is #%s# ", orig);

encb2( orig, secret);

printf(" Secret is #%s# ", secret);

decb2( secret, show);

printf(" Show   is #%s# ", show);

Explanation / Answer

int main ()
{

int i = 2, n ;

printf("Enter an integer:") ;
scanf("%i" ,&n) ;

if ( n == 0 )
{
return 1 ;
}
printf("Prime factors of '%d': ", n);

while(n>i) {
/* if valid prime factor */
if(n % i == 0) {
printf("%d x ", i);
n /= i;
}
/* else: invalid prime factor */
else {
if(i == 2)
i = 3;
else
i += 2;
}
}

/* print last prime factor */
printf("%d ", i);
}