Functions and Recursions – Strings – Problem #1
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write a program which reads first name and family name of a person. It also reads a character (M or F) to know the gender of the person (M for male and F for female). Finally forms a string containing the full name of the person in the following format. A prefix (‘Mr.’ for male and ‘Ms.’ for female) followed by a space and then the first letter of the first name (in uppercase) followed by a (.), a space and the family name, first letter of which should be in uppercase. For example given the input “Santanu”, “John” and ‘M’, it should form a string “Mr. S. John”. Print the string containing the full name in the above format, and also print the number of vowels, and consonants in it. Run the program with the following input data set: (i) “Abdel”, “Halim”, ‘M’ (ii) “Upasana”, “Naskar”, ‘F’ (iii) “Vellupuri”, “Sudarshan”, ‘M”