TCS Coding 1. The program will recieve 3 English words inputs from STDIN These three words will be read one at a time, in three separate line

1. The program will recieve 3 English words inputs from STDIN

  1. These three words will be read one at a time, in three separate line
  2. The first word should be changed like all vowels should be replaced by *
  3. The second word should be changed like all consonants should be replaced by @
  4. The third word should be changed like all char should be converted to upper case
  5. Then concatenate the three words and print them

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*[email protected]

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

Test Cases

Case 1

Input

  • how
  • are
  • you

Expected Output : h*[email protected]

Case 2

Input

  • how
  • 999
  • you

Expected Output : h*w999YOU

#include<stdio.h>
#include<conio.h>
#include<string.h>

int main()
{
int i;
char a[100],b[100],c[100];

    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);

    for(i=0;a[i]!='\0';i++)
    {
        if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U')
            a[i]='*';
    }

    for(i=0;b[i]!='\0';i++)
    {
if((b[i]>='a'&&b[i]<='z') || (b[i]>='A'&&b[i]<='Z')) if(!(b[i]=='a'||b[i]=='e'||b[i]=='i'||b[i]=='o'||b[i]=='u'||b[i]=='A'||b[i]=='E'||b[i]=='I'||b[i]=='O'||b[i]=='U')) b[i]='@'; } for(i=0;c[i]!='\0';i++) { if(c[i]>='a'&&c[i]<='z') c[i]=c[i]-32; } printf("%s%s%s",a,b,c); return 0; }
#include<iostream>
#include<string.h>

using namespace std;
int main() { int i; char a[100],b[100],c[100]; cin >> a; cin >> b; cin >> c; for(i=0;a[i]!='\0';i++) { if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U') a[i]='*'; } for(i=0;b[i]!='\0';i++) {
if((b[i]>='a'&&b[i]<='z') || (b[i]>='A'&&b[i]<='Z')) if(!(b[i]=='a'||b[i]=='e'||b[i]=='i'||b[i]=='o'||b[i]=='u'||b[i]=='A'||b[i]=='E'||b[i]=='I'||b[i]=='O'||b[i]=='U')) b[i]='@'; } for(i=0;c[i]!='\0';i++) { if(c[i]>='a'&&c[i]<='z') c[i]=c[i]-32; } cout << a << b<< c; return 0; }

26 comments on “TCS Coding 1. The program will recieve 3 English words inputs from STDIN These three words will be read one at a time, in three separate line”


  • Sourav

    Python Code:
    a = str(input())
    b = str(input())
    c = str(input())

    v = [‘a’,’e’,’i’,’o’,’u’]
    con = [‘b’,’c’,’d’,’f’,’g’,’h’,’j’,’k’,’l’,’m’,’n’,’p’,’q’,’r’,’s’,’t’,’v’,’w’,’x’,’y’,’z’]
    for i in a:
    if i in v:
    x = a.replace(i,’*’)
    for i in b:
    if i in con:
    y = b.replace(i,’@’)
    else:
    y = b
    z = c.upper()

    print(x+y+z)


  • Bharath

    import string
    word1=input()
    word2=input()
    word3=input()
    vowel=[“a”,”e”,”i”,”o”,”u”]
    alphabet=[“b”,”c”,”d”,”f”,”g”,”h”,”j”,”k”,”l”,”m”,”n”,”p”,”q”,”r”,”s”,”t”,”v”,”w”,”x”,”y”,”z”]
    alphabet_string = string.ascii_lowercase
    alphabet_list=list(alphabet_string)
    for i in word1.lower():
    if i in vowel:
    word1=word1.replace(i,”%”)
    for j in word2.lower():
    if j in alphabet:
    word2=word2.replace(j,”#”)
    word3=word3.upper()
    result=word1+word2+word3
    print(result)


  • Anubhav

    java code
    import java.util.Scanner;
    import java.lang.*;
    class Name
    {
    public static void main(String args[])
    {
    Scanner sc=new Scanner(System.in);
    String words[]=new String[3];
    System.out.print(“Enter the 3 words :”);
    for(int j=0;j<words.length;j++)
    {
    words[j]=sc.next();
    {
    if(j==0)
    {
    char a[]=words[j].toCharArray() ;
    for(int i=0;i<a.length;i++)
    {
    if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U')
    a[i]='*';
    }

    for(int i=0;i<a.length;i++)
    {
    System.out.print(a[i]);
    }
    System.out.print(" ");
    }
    if(j==1)
    {
    char a[]=words[j].toCharArray();
    for(int i=0;i<a.length;i++)
    {
    if(!(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U'))
    a[i]='@';
    }

    for(int i=0;i<a.length;i++)
    {
    System.out.print(a[i]);
    }
    System.out.print(" ");
    }
    if(j==2)
    {
    char a[]=words[j].toCharArray();
    for(int i=0;i<a.length;i++)
    {
    if(Character.isLetter(a[i])&&Character.isLowerCase(a[i]))
    a[i]=Character.toUpperCase(a[i]);
    }
    for(int i=0;i<a.length;i++)
    {
    System.out.print(a[i]);
    }
    }
    }
    }
    }
    }


  • Riya

    Program in python:
    vowel={‘a’,’e’,’i’,’o’,’u’}
    a=str(input())
    b=str(input())
    c=str(input())
    for x in a:
    if x in vowel:
    a=a.replace(x,’*’)
    for y in b:
    if y not in vowel:
    b=b.replace(y,’@’)
    c=c.upper()
    print(a+b+c)


  • Souvik

    word1 = input()
    word2 = input()
    word3 = input()
    l1 = list(word1)
    l2 = list(word2)
    vowels = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’, ‘A’, ‘E’, ‘I’, ‘O’, ‘U’]

    for i in range(0, len(l1)):
    if l1[i] in vowels:
    l1[i] = ‘*’

    for j in range(len(word2)):
    if l2[j] in vowels:
    continue
    else:
    l2[j] = ‘@’

    print(”.join(l1) + ”.join(l2) + word3.upper())


  • Pawan

    a=str(input())
    b=str(input())
    c=str(input())

    v=[‘a’,’e’,’i’,’o’,’u’]
    for i in a:
    if i in v :
    r=a.replace(i,’*’)
    for i in b:
    if i not in b :
    s=b.replace(i,’@’)

    last=c.upper()
    final=r + s + last
    print(final)


  • Harmeet

    this is for java
    import java.util.Scanner;

    public class changingwords {

    public static void main(String s[]){
    String s1,s2,s3;
    Scanner sin=new Scanner(System.in);

    s1=sin.nextLine();
    s2=sin.nextLine();
    s3=sin.nextLine();

    System.out.println(s1.replaceAll(“[AaEeIiOoUu]”, “*”)+s2.replaceAll(“[^AaEeIiOoUu]”, “@”)+s3.toUpperCase());

    }
    }


  • Raj

    a=input()
    b=input()
    c=input()
    for i in a:
    if(i==”a” or i==”e” or i==”i” or i==”o” or i==”u” or i==”A” or i==”E” or i==”I” or i==”O” or i==”U”):
    print(“*”,end=””)
    else:
    print(i,end=””)
    for i in b:
    if not (i==”a” or i==”e” or i==”i” or i==”o” or i==”u” or i==”A” or i==”E” or i==”I” or i==”O” or i==”U”):
    print(“@”,end=””)
    else:
    print(i,end=””)
    print(c.upper(),end=””)