Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

11 Changing the Datatype of Data It can happen that a variable has some content that makes sense in a datatype different from the datatype

11 Changing the Datatype of Data

It can happen that a variable has some content that makes sense in a datatype different from the datatype of that variable. We can change the datatype that is applied to the data. For example, we might have a character variable, and wish to do some arithmetic with it. The Caesar cipher starts with a letter of the (let us say, English) alphabet, and maps it to the letter offset by some integer. Suppose we map a letter to the letter next after it. For z, it becomes a. So we have a character, we want to think of it as a number, so that we can add 1 to it, so long as it is not a z. We can use the process of casting.

char aChar = a;

int aCharI = (int) aChar;

int anotherInt = aCharI+1;

char anotherChar = (char)anotherInt;

printf("The resulting character is %c. ", anotherChar);

1. Using the code above, change it so that the letter is initially some alphabetic character other than a, but not w,x,y or z also not W,X,Y or Z. Also, add 3 to it. Note that, in ASCII, capital letters start at A=65, and small letters start at a=97. Write code that will change a capital letter into the corresponding lower case letter.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

What were your most important educational experiences?

Answered: 1 week ago

Question

Which personal relationships influenced you the most?

Answered: 1 week ago