Array and Strings – Strings – Problem #8
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write a C Program that reads in a string of characters (without blanks in between) and then prints only the unique alphabets (replacing all upper case elements by their lower case) as a string which has the vowels first followed by the consonants after all the vowels. No numeric or other non-alphabet is printed. If there is no alphabet, print “No Alphabet in String”. For example, if the string read is IITKharagpur$India then the program will first print IITKharagpur$India and then print iautkhrgpnd. (It could also print the result string in any sequence, like aiutkdhgrnp, etc ). Save the file as A08_<Roll Number>.c (example A08_21AG10002.c). Build, Run and test it for the given data. Then upload the .c file for the Assignment. [20 Marks: 5 marks for intermediate submission, 15 marks for final submission] In particular, you will do the following: 1. Read in a character string in %s format and store it in a character array. Print the string read in and create a new line. 2. In a separate array, create a string formed by only the unique alphabets of the original string, replacing all upper case characters by their lower case, removing all non-alphabets and having the vowels before the consonants. 3. Print this new string in a suitable fashion and create a new line. If there is no alphabet, print “No Alphabet in String”. (Do not use any special string library function except to read and write in %s format.) [If you wish, you can also use an intermediate third array for your work, but that is not necessary] Test Data: a) IITKharagpur$India b) PDSLabSection11 c) A*Algorithm#AI d) &*5123!