The program will recieve 3 English words inputs from STDIN

Write a program that meet the following requirement:
1.The program will receive 3 English words inputs from STDIN

2.These three words will be read one at a time, in three separate line

3.The first word should be changed like all vowels should be replaced by $

4.The second word should be changed like all consonants should be replaced by #

5.The third word should be changed like all char should be converted to upper case

6.Then the program will concatenate the three words and print to STDOUT. 

Other than these concatenated word, no other characters/string should or message should be written to STDOUT

For example if you print how are you then output should be h$wa#eYOU.


You can assume that input of each word will not exceed more than 5 chars


#include <stdio.h>
#include<string.h>
int main(void) {

char *str1= malloc(sizeof(char)*256);
char *str2= malloc(sizeof(char)*256);
char *str3= malloc(sizeof(char)*256);
scanf("%s%s%s",str1,str2,str3);

int p1 = strlen(str1);
int p2 = strlen(str2);
int p3 = strlen(str3);
for(int i=0;i < p1;i++)
{
if(str1[i]=='a'||str1[i]=='e'||str1[i]=='i'||str1[i]=='o'||str1[i]=='u')
{
str1[i]='$';
}
}
for(int i=0;i < p2;i++)
{
if(str2[i]!='a' && str2[i]!='e' && str2[i]!='i' && str2[i]!='o' && str2[i]!='u')
{
str2[i]='#';
}
}
for(int i=0;i < p3;i++)
{
str3[i]=str3[i]-32;
}

printf("%s%s%s",str1,str2,str3);
return 0;
}

Input:    how are you
Output:   h$wa#eYOU

Post a Comment

0 Comments