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; }

75 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”


  • Aviral

    Using Java CODE :-
    ===========
    import java.util.*;
    public class Main
    {
    public static void main(String[] args) {
    Scanner s=new Scanner(System.in);
    System.out.println(“Enter First String”);
    String str1=s.nextLine();
    System.out.println(“Enter Second String”);
    String str2=s.nextLine();
    System.out.println(“Enter third String”);
    String str3=s.nextLine();
    str3=str3.toUpperCase();
    String res=””;
    for(int i=0;i<str1.length();i++)
    {
    char ch=str1.charAt(i);
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
    {
    str1=str1.replace(ch,'*');
    }//end of if
    }//end of for loop
    for(int i=0;i<str2.length();i++)
    {
    char ch=str2.charAt(i);
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
    {
    continue;
    }//end of if
    else if(ch=='0'||ch=='1'||ch=='2'||ch=='3'||ch=='4'||ch=='5'||ch=='6'||ch=='7'||ch=='8'||ch=='9')
    {
    continue;
    }
    else{
    str2=str2.replace(ch,'@');
    }
    }//end of for loop
    res=res.concat(str1).concat(str2).concat(str3);
    System.out.println(res);
    }
    }