Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to accept a string from the keyboard, reverse the string, capitalize all alphabet chars in the string, print each char on its

Write a program to accept a string from the keyboard, reverse the string, capitalize all alphabet chars in the string, print each char on its own line, print the number of alphabet chars capitalized and print the length of the string. If the prompt and input string is:

Enter a string: Let us C!

The output should be: !

C

S U T E L

The string is 9 chars and 4 chars were capitalized.

You should write one function for each operation and call them from main. The string and the integer for length should be declared in main and passed to called functions. You should try sketching a rough algorithm and test it on paper before coding. You can NOT use C library functions to get the length of a string, convert to upper case and test for lower case. You should write you own functions for these operations.

  1. Main function calls other functions 2. Function to get the length of a string 3. Function to test if a char is lower case (Hint: for char c, c >= a works) 4. Function to convert a lower case char to uppercase (Hint: Look at positions in ASCII table) 5. Function to get string from keyboard. Hint: scanf will not work for strings with spaces. Google gets() and make sure that the string is sufficiently large to contain reasonable size input. 6. Function to reverse string. 7. Function to capitalize all alpha chars and count number capitalized. 8. Function to print output.

Hint for extra credit: remember that strings are null terminated and the all characters in upper and lower case are in contiguous ranges in the ASCII table. There is a 20% penalty for not using meaningful function names, variable names and comments. The only library included should be stdio.h.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions