Function with array to find number of vowels and consonants

This is a discussion on Function with array to find number of vowels and consonants within the C Programming forums, part of the General Programming Boards category; Here is the working code: Code: #include <stdio.h> #include <stdlib.h> #include "arrayv.h" /* This function will find the number of ...

  1. #46
    Registered User georgio777's Avatar
    Join Date
    Sep 2009
    Posts
    70
    Here is the working code:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include "arrayv.h"
    
    /* This function will find the number of vowels in the word and output their position using a * to
    mark the vowels position. */
    int arrayv()
    {
    	int i, j, flag;
    	char strv[11] = {'a','e','i','o','u','A','E','I','O','U','\0'};
    	char str[100], repeat;
    	printf("Number of vowels in a word:\n");
    	do{
    	printf("\n");
    	printf("Please enter a word: ");
    	scanf("%s", str);
    	printf("\n");
    	printf("%s\n", str);
    	for(i=0; str[i] != '\0'; i++)
    	{	flag = 0;
    		for(j=0; strv[j] != '\0'; j++)
    		{
    			if (str[i] == strv[j])
    			{
    			printf("*");
    			flag = 1;
    			break;
    			}
    		}
    		if (flag == 0)
    		{
    		printf(" ");
    		}
    	}
    	printf("\n");
    	printf("\n");
    	printf("Play Again? ");
    	getchar();
    	repeat = getchar();
    	while ( getchar() != '\n');
    	} while(repeat == 'Y' || repeat == 'y');
    	
    	return EXIT_SUCCESS;
    }

  2. #47
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Quote Originally Posted by georgio777 View Post
    I promise it would happen again!
    Hey now!

  3. #48
    Registered User georgio777's Avatar
    Join Date
    Sep 2009
    Posts
    70
    Quote Originally Posted by nadroj View Post
    Hey now!
    Hahahahahahaha

    Sorry

    I promise it would NOT happen again!

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Count the number of vowels, consonants, digits etc.
    By kumar14878 in forum C Programming
    Replies: 3
    Last Post: 05-09-2005, 12:34 AM
  2. function supposed to strip vowels
    By MB1 in forum C++ Programming
    Replies: 11
    Last Post: 04-23-2005, 05:44 PM
  3. Very odd segmentation fault/core dump.
    By ChristianTool in forum C Programming
    Replies: 19
    Last Post: 04-26-2004, 06:38 AM
  4. Replies: 4
    Last Post: 11-23-2003, 06:15 AM
  5. Massive Function Problem
    By Marc Sharp in forum C Programming
    Replies: 10
    Last Post: 11-19-2003, 07:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21