Help Needed

This is a discussion on Help Needed within the C++ Programming forums, part of the General Programming Boards category; Write a program that inputs a sequence of characters and outputs the number of vowels..!! Its not working.!! if anyone ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    112

    Exclamation Help Needed

    Write a program that inputs a sequence of characters and outputs the number of vowels..!! Its not working.!!
    if anyone can guide.!!
    Code:
    #include<iostream.h>
    #include<conio.h>
    int isVowel (char x);
    int main()
    {
    char word;
    int count=0,i;
    clrscr();
    cout<<"Enter sequence of characters";
    cin>>word;
    i=isVowel(word);
    	if (i==1)
    	{
    	count++;
    	cout<<count<<endl;
    	}
    		else
    		{
    		cout<<"No Vowels";
    		getch();
    		return 0;
    		}
    		
    {
    char a,e,i,o,u,x;
     if (x=='a')
    {
    return 1;
    }
    	if (x=='e')
    	{return 1;
     	}
    		if (x=='i')
    		{return 1;
    		 }
    		
    			if (x=='o')
    			{return 1;
    			}
    				if (x=='u')
    				{return 1;
    				}
    }
    {
     return 0;
    }
    }

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    What errors are you getting?

    All I see is ASCII art drawing of a staircase
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    112
    int isVowel (char x)
    undefined module..!!

  4. #4
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    where is ur isvowel() function defined? define it in the code.like this.
    Code:
    int isVowel(char x)
    {
    //do something
    return something;
    }
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    112
    didnt get you.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,446
    A few suggestions:
    • Change <iostream.h> to <iostream>
    • Get rid of #include<conio.h> and getch()
    • Indent your code properly
    • Change the isVowel function to return a bool instead of an int
    • Define the isVowel function
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by Fatima Rizwan View Post
    didnt get you.
    every function should be defined somewhere in the code to use it. You have declared isVowel before main but not defined it. So define it first.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  8. #8
    Registered User
    Join Date
    Mar 2009
    Posts
    112
    i dun know how to indent it, i use turbo c 3..so iostream dun work on it..!!
    n how to define isVowel..!!
    Bool also dun work in this compiler so i have to use int..!!

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,446
    Quote Originally Posted by Fatima Rizwan
    i dun know how to indent it, i use turbo c 3..so iostream dun work on it..!!
    n how to define isVowel..!!
    Bool also dun work in this compiler so i have to use int..!!
    Change to a more standard compliant compiler, or risk acquiring an obsolete skill set.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by Fatima Rizwan View Post
    i dun know how to indent it, i use turbo c 3..so iostream dun work on it..!!
    n how to define isVowel..!!
    Bool also dun work in this compiler so i have to use int..!!
    turbo c is a fossil(as they say so). It's quite an old compiler, so it doesn't copes up with the standards. That's why data-type bool and <iostream> are not compatible with it.
    For definition of a function, you should refer to some functions tutorials. Here's an example.
    Code:
    int add(int,int);//function declared here
    int main(void)
    {
    int a=3,b=5;
    sum=add(a,b);//function add called by main
    printf("%d",sum);
    return 0;
    }
    //Here's the definition
    int add(int x, int y)
    {
    int s;
    s=x+y;
    return s;
    }
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  11. #11
    Registered User
    Join Date
    Mar 2009
    Posts
    112
    Code:
    #include<iostream.h>
    #include<conio.h>
    int isVowel(char x);
    int main()
    {
    clrscr();
    int i=0;
    char word[50];
    
    
    cout<<"Enter characters:";
    cin>>word[50];
    i=isVowel(word[50]);
    cout<<i;
    for (i=0; i<word[50] ; i++)
    if (i==1 )
    {
    cout<<"\nNo of vowels:"<<i;
    }
    getch();
    return 0;
    }
    
    int isVowel(char x)
    {
     if (x=='a' || x=='e' || x=='i' || x=='o'|| x=='u')
    return 1;
    
    else
         { return 0; }
    
    }


    write a sequence of letters and count no. of vowels..!!
    kindly identify the logical error..!!

  12. #12
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,446
    Quote Originally Posted by Fatima Rizwan
    kindly identify the logical error..!!
    You shoud be calling isVowel() in the loop, and using word[50] is simply wrong since it is out of bounds. You should also be less self-centred and use "i" less often.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. lock needed in this scenario?
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-25-2008, 07:22 AM
  4. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM
  5. semi-colon - where is it needed
    By kes103 in forum C++ Programming
    Replies: 8
    Last Post: 09-12-2003, 05:24 PM

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