#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main (int argc,char **argv)
{
char *a,*b,c;
int t,e;
if (argc<2) return(0);
a=argv[1];
b=a;
e=strlen(b);
for (t=0;t<=e;t++)
{
c = *b;
if (c>='A'&&c<='Z') c -= 'A'-'a';
if (c=='a'c=='e'c=='i'c=='o'c=='u') b++;
else *a++ = *b++;
}
printf ("%s\n",argv[1]);
return(0);
}
// Replace all vowels in str with 'z'
void replaceWithZ(char* str) {
int i = 0;
while(str[i] != 'z') {
if(isVowel(str[i])) {
str[i] = 'z';
}
++i;
}
}
// Returns 1 if ch is a vowel, 0 otherwise
int isVowel(const char ch) {
switch(ch) {
case 'a':case 'A':
case 'e':case 'E':
case 'i':case 'I':
case 'o':case 'O':
case 'u':case 'U':
return 1;
}
return 0;
}
// Sample call
int main() {
char str[] = "HELLO";
printf("%s\n", str);
replaceWithZ(str);
printf("%s\n", str);
return 0;
}
Basically you could have a method like this:
//returns the indexes of the vowels in char array s, optionally including Y's
int[] FindVowels(char[] s, boolean FindYs)
{
//store the number of vowels found
int VowelCount = 0;
char[] Vowels;
int[] vowelIndexes = new int[s.length];
if(FindYs) vowels = {'a','e','i','o','u','y'};
else vowels = {'a','e','i','o','u'};
for(int si = 0; si < s.length; si++)
{
for(int vi = 0; vi < vowels.length; vi++)
{
if(vowels[vi]== s[si])
{
vowelIndexes[VowelCount] = si;
VowelCount++;
}
}
}
int[] returnarray = new int[Vowelcount];
for(int i = 0; i < VowelCount; i++)
returnarray[i]=vowelindexes[i];
return returnarray;
}
Is this a C-program?
#include<stdio.h>
#include<conio.h>
int main()
{
char ar[20];
int vowc=0,i;
printf("Enter the array\n");
gets(ar);
for(i=0;i<20;i++)
{
switch(ar[i])
{
case 'a' :
case 'A' :
case 'e' :
case 'E' :
case 'i' :
case 'I' :
case 'o' :
case 'O' :
case 'u' :
case 'U' :
vowc++;
break;
default : break;
}
}
printf("%d",vowc);
return 0;
}
#include <stdio.h>
RemoveVowels (char *str) {
char *new = str;
while (*str != '\0') {
if (tolower(*str) != 'a' && tolower(*str) != 'e' && tolower(*str) != 'i' && tolower(*str) != 'o' &&
tolower(*str) != 'u') *(new++) = *str;
str++;
}
*(new) = '\0';
}
int main (int argc, char**argv) {
if (argc > 1) {
RemoveVowels (argv[1]);
printf ("%s\n", argv[1]);
return 0;
}
return 1;
}
That's easy to do!This script will get the POST data from an HTML form and check if it is a vowel.
Reference:cprogramming-bd.com/c_page1.aspx# array programming
To write a C++ program to display the student details using class and array of object.
How to write a program for mouse in microprocessor?
the example of array over charcter variables is char ["string"]
That's easy to do!This script will get the POST data from an HTML form and check if it is a vowel.
build an array of vowels then do a foreach on the array and then explode the string on the array value and the answer is -1 of the result
Reference:cprogramming-bd.com/c_page1.aspx# array programming
To write a C++ program to display the student details using class and array of object.
How to write a program for mouse in microprocessor?
the example of array over charcter variables is char ["string"]
write an assembly language program to find sum of N numbers
array type
int findMax(int *array) { int max = array[0]; for(int i = 1; i < array.length(); i++) { if(array[i] > max) max = array[i] } return max; }
maxValue = function (array) {mxm = array[0];for (i=0; i<array.length; i++) {if (array[i]>mxm) {mxm = array[i];}}return mxm;}; i don't know
public static int[] reverseArray(int[] array) { int i = 0, j = array.length - 1; for (i = 0; i < array.length / 2; i++, j--) { int temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; }
Yes, you can but the array must be char-type. ... int arraySize = 3;char myArray[arraySize]; ... for (intarrayIndex = 0; arrayIndex < arraySize; arrayInsex++) { cin >> myArray[arrayIndex]; //It will write three character (keys which you pressed) in myArray} ...