Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use C to programing! The goal of this exercise is to help you practice the use of arrays and strings. You will write a little

Use C to programing!

The goal of this exercise is to help you practice the use of arrays and strings. You will write a little program to change the contents of a string in various ways. Please read the description below carefully.

Conditions: You are not allowed to use the string library 'string.h' (the point of the exercise is for you to write the functions that handle the strings).

Your program will:

- Declare a string in main(), the text in this string will be:

A strIng is jUst a bunch Of chArs sittIng togEthEr in A row!

(without the quotes, of course)

- Write a function called

pidgin( .... )

(you have to figure out the input parameters and return type)

This function accepts an input string and swaps the order of each consecutive pair of characters. So, for example, if the input string contains

"This is an example"

then after calling the pidgin() function your string should contain

"hTsii snae axpmel"

Your function will have to figure out what to do about the end of line delimiter. And we expect you to decide what is reasonable to do in the case where the length of the string is odd.

Your 'pidgin()' function must not depend on the input string having a specific length (we can test it with different strings and it should work!).

- Write a function called

vowel_caser( .... )

(again, you have to figure out what the input parameters and return type should be).

This function accepts an input string, and changes the case of each vowel (upper case vowels 'A,E,I,O,U' become lower case 'a,e,i,o,u' and vice-versa).

For example, if the input string is

"And Once There Was An Active Volcano On The Island"

After calling 'vowel_caser()' the string should become

"and oncE ThErE WAs an actIvE VOlcAnO on ThE islAnd"

This is a good time for you to become familiar with a few useful library functions: 'isupper()', 'islower()', 'toupper()', and 'tolower()'. These are defined in the header file 'ctype.h'. There are many more useful functions in this library! keep it in mind should you need to do this sort of processing in the future.

- Test both functions and make sure they work!

Your main() function will:

- Declare and initialize the string "A strIng is jUst a bunch Of chArs sittIng togEthEr in A row!

- Print the original string

- Call the function pidgin()

- Print the resulting string

- Call vowel_caser() on the resulting string

- Print the resulting string

If all goes well, on the example string we gave you, your program will output exactly the text shown below (just the 3 lines of text - each in its own row):

A strIng is jUst a bunch Of chArs sittIng togEthEr in A row! AtsIrgni sUjtsa b nuhcO fhcrA sisttnI gotEghtrEi n Aor!w atsirgnI sujtsA b nUhco fhcra sIsttni gOteghtreI n aOr!w

Once more, let me stress we could test your code on a different string - so make sure it works not just for the example above!

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

Real Time Database Systems Architecture And Techniques

Authors: Kam-Yiu Lam ,Tei-Wei Kuo

1st Edition

1475784023, 978-1475784022

More Books

Students also viewed these Databases questions