C-Programming project C7]: ubbi dubbi Due Tuesday, 11/29/2016, 12:59:59pm Projec
ID: 3777515 • Letter: C
Question
C-Programming
project C7]: ubbi dubbi Due Tuesday, 11/29/2016, 12:59:59pm Project Goals The goals of this project are to explore the strings, command-line arguments, and the c string library. Important Notes: 1. Comments: Header comments are required on all files, for each function, and recommended throughout the rest of the program. Guidelines for header comments and function comments were discussed in lecture or online (google c comment styl e or go to https://www.cs.swarthmore.edu/-newhall/u c codestyle.html). Points nixhel be deducted f no header function mments are included. Project For this project you will write a program that translates English into Ubbi Dubbi. Don't speak Ubbi Dubbi? W ://youtu.be/KIVgBbYlgHI?t-1m21s, this starts in the middle, the rest of the video is a lot of ning and Klingon....The key is to add Mub" before any vowel in a syllable. S "hello" becomes "hubellubon and "extra" becomes "ubextruban (forfull rules, go to Wikipedia (yes there are rules on wikipedia /en.wikipedia.org/wiki/Ubl dubbi 1. Read in a word (or a sentence using as a command-line argument 2. Create a new string big enough to hold the ubbi-dubbified version of what the user entered 3. Copy the characters in the original string to the new string, but a. For each vowel in the string, you must add "ub" before the vowel in the new string i. f the vowel is capital, then you must add "U b. Then copy the vowel to the new string c. Any other character should just be copied to the new string (whitespace included) 4. Then print out both the original and ubbi-dubbified versions of the string Your code should work ke this: /ubbidubbi Hello [Hello] in Libbi-dubbi is IHubellubo /ubbidubbi HELLO IHELLO1 in Libbi-dubbi is IHUBELLUBOExplanation / Answer
Code:
#include "stdio.h"
#include "string.h"
int main(int argc, char *argv[]) {
char str1[100],str2[100];
strcpy(str1, argv[1]);
printf("%s ",str1);
int i,j=0;;
for(i=0;i<strlen(str1);i++){
if(str1[i]=='a' || str1[i]=='e' ||str1[i]=='i' ||str1[i]=='o' ||str1[i]=='u'){
str2[j++] = 'u';
str2[j++] = 'b';
str2[j++] = str1[i];
}else{
str2[j++] = str1[i];
}
}
str2[j++] = '';
printf("%s ",str2);
return 0;
}
/*
Output:
sh-4.2$ main extra
extra
ubextruba
sh-4.2$ main umbrella
umbrella
ubumbrubelluba
*/
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.