MindTree Coding Questions in Easy Section – 2

MindTree Automata Coding Section Question 2

Also, if you want to study for MindTree and get previous questions in MindTree Quants, Verbal and Logical section, visit our MindTree Dashboard here.

Please also comment down the code in other languages.

Ques. Remove all Vowels from a String using Pointers concept?

#include < stdio.h >

#include < stdlib.h >

#include < string.h >

#define TRUE 1

# define FALSE 0

int check_vowel(char);
main() {
char string[100], * temp, * pointer, ch, * start;
printf(“Enter a string\n”);
gets(string);
temp = string;
pointer = (char * ) malloc(100);
if (pointer == NULL) {
printf(“Unable to allocate memory.\n”);
exit(EXIT_FAILURE);
}
start = pointer;
while ( * temp) {
ch = * temp;
if (!check_vowel(ch)) { * pointer = ch;
pointer++;
}
temp++;
} * pointer = ‘\0’;
pointer = start;
strcpy(string, pointer); /* If you wish to convert original string */
free(pointer);
printf(“String after removing vowel is \”%s\”\n”, string);
return 0;
}
int check_vowel(char a) {
if (a >= ‘A’ && a <= ‘Z’) a = a + ‘a’ – ‘A’;
if (a == ‘a’ || a == ‘e’ || a == ‘i’ || a == ‘o’ || a == ‘u’) return TRUE;
return FALSE;

4 comments on “MindTree Coding Questions in Easy Section – 2”