Consider ASCII code for the data security functional C progr

Consider ASCII code for the data security functional C program. All variables and headers are property declared. Char s[64]; unsigned *ptr1 = s; size_t i, j, k; puts (\"Enter a line of text: \\a\ \"); fgets(s, 64, stdin); puts(\"\ \\a convert to proper case\"); for (I = 0; s[i] ! = \'\\0\'; ++i) {printf(\"%c:%d\\t\", tolower (s[i] - (i*2)), tolower [s[i] - (I*2))); How many bytes and how many bits long is the s array in the above the ptf1 hex address is given as 0 0 2 8 F E 7 0. What is the decimal equivalent value for ptr1? Does the s array pointer value move towards lower value or higher value as the data is entered? Character string DFGHJ entered for fgets(s, 64, stdin); what are the characters printed with the \'for\' loop? What is the final value of \'I\' variable when the for loop terminates?

Solution

a) :   array s contains 64 elements and it is an array of type \'char\'. Bytes taken by each element of array is 1bytes, thus s is 64 bytes long and s is 512 bits long

b) : hex address of ptr1 is 0028FE70. The decimal equivalent should be :

= 0*1 + 7*16 + 14*(16^2) + 15*(16^3) + 8*(16^4) + 2*(16^5)

= 2686576

c) : As data is entered in s, s array pointer remains same. It still points to beginning of the array.

d) : fgets(s,64,stdin) doesn\'t necessarily read 64 characters. If newline or end-of-file is reached, then it stops reading any more characters. Now if input string is \"DFGHJ\" then 5 characters are printed with \"for\" loop

e) : final value of \'i\' variable would be equal to the length of input string. For example if input string is \"DFGHJ\", then final value of \'i\' variable is 5

 Consider ASCII code for the data security functional C program. All variables and headers are property declared. Char s[64]; unsigned *ptr1 = s; size_t i, j, k

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site