Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript

#include <stdio.h>
#define MAX 100

//function prototypes

/*
This function will return o if 'ch' is vowel
else it will return 1
*/
char isVowel(char ch);

/*
This function will eliminate/remove all vowels
from a string 'buf'
*/
void eliminateVowels(char *buf);

/*main function definition*/
int main()
{
    char str[MAX]= {0};

    //read string
    printf("Enter string: ");
    scanf("%[^
]s",str); //to read string with spaces

    //print Original string
    printf("Original string: %s
",str);

    //eliminate vowles
    eliminateVowels(str);
    printf("After eliminating vowels string: %s
",str);

    return 0;
}

//function definitions

char isVowel(char ch)
{
    if(	ch=='A' || ch=='a' ||
            ch=='E' || ch=='e' ||
            ch=='I' || ch=='i' ||
            ch=='O' || ch=='o' ||
            ch=='U' || ch=='u')
        return 0;
    else
        return 1;
}

void eliminateVowels(char *buf)
{
    int i=0,j=0;

    while(buf[i]!='')
    {
        if(isVowel(buf[i])==0)
        {
            //shift other character to the left
            for(j=i; buf[j]!=''; j++)
                buf[j]=buf[j+1];
        }
        else
            i++;
    }
}
Source by elzero.org #
 
PREVIOUS NEXT
Tagged: #javascript
ADD COMMENT
Topic
Name
5+3 =