3 - Remove all vowels from a given string using pointers
3 - Remove all vowels from a given string using pointers
Problem Statement
Input:
CodeforInteview
Code for Interview
#include <stdio.h>
#include <string.h>
int check_vowel(char);
int main()
{
char s[100], t[100];
int i, j = 0;
scanf("%[^\n]s",s);
if(check_vowel(s[i]) == 0) {
t[j] = s[i];
j++;
t[j] = '\0';
strcpy(s, t);
Code for Interview
printf("%s\n", s);
return 0;
int check_vowel(char c)
switch(c) {
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
return 1;
Code for Interview
default:
return 0;
In C using pointers
Code for Interview
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define TRUE 1
#define FALSE 0
int check_vowel(char);
int main()
gets(string);
temp = string;
pointer = (char*)malloc(100);
exit(EXIT_FAILURE);
start = pointer;
Code for Interview
while(*temp)
ch = *temp;
if ( !check_vowel(ch) )
*pointer = ch;
pointer++;
temp++;
*pointer = '\0';
pointer = start;
strcpy(string, pointer);
free(pointer);
printf("%s\n", string);
return 0;
Code for Interview
int check_vowel(char a)
a = a + 'a' - 'A';
return TRUE;
return FALSE;