Help wanted in C++ programming

Jul 8, 2007
1,138
156
0
Melbourne
hey guys does anybody here know C++??

This is the question.

Write a program using arrays to input a sentence and calculate the vowels in the sentence. Can any genius here help me? Pls? Need the program code.
 

Sudantha_s

Member
Feb 2, 2007
3,516
7
0
Assassin Brotherhood
chinthakapathir said:
hey guys does anybody here know C++??

This is the question.

Write a program using arrays to input a sentence and calculate the vowels in the sentence. Can any genius here help me? Pls? Need the program code.









#include<stdio.h>

main()
{

char str[25];
char search;
int count=0;

printf("Enter a String : ");
fflush(stdin);
gets(str);

printf("Enter a Word to Search : ");
scanf("%c",&search);

for(int i=0;i<25;i++)
{
if(str==search)
{
count++;
}
}

printf("That Characther Found %d Time(s)",count);
}
 
Jul 8, 2007
1,138
156
0
Melbourne
Sudantha_s said:
#include<stdio.h>

main()
{

char str[25];
char search;
int count=0;

printf("Enter a String : ");
fflush(stdin);
gets(str);

printf("Enter a Word to Search : ");
scanf("%c",&search);

for(int i=0;i<25;i++)
{
if(str==search)
{
count++;
}
}

printf("That Characther Found %d Time(s)",count);
}


Thanks i got some kind of idea about it. can you kindly type this in c++ commands coz i dont know these commands fflush,gets. Only did the basic stuff in C. Need c++ coding. thanks .
 

Sudantha_s

Member
Feb 2, 2007
3,516
7
0
Assassin Brotherhood
chinthakapathir said:
ela thanks anyway machan


This is ur coding using C




#include<stdio.h>

main()

{

char word[10];
int val=0;
int i;

printf("Enter a String : ");
gets(word);

for(i=0;word!='\0';i++)
{

if(word=='a'||word=='e'||word=='i'||word=='o'||word=='u')
{
val++;

}

}

printf("Vowel Count is : %d",val);
printf("\nNumber of Constances : %d",i-val);




}
 

¤--bACarDi--¤

Well-known member
  • Jan 9, 2009
    12,130
    288
    83
    124.43.xxx.xxx
    Machan meken count wenne vowel sounds nemei vowel letters....k
    Awlak thiyenawanam kiyapan....;)

    Code:
    #include <iostream>
    using namespace std;
    int main ()
    {
    char string[25];
    int count=0;
    cout<<"Enter String:";
    cin>>string;
    
    for (int j=0;j<26;j++)
    { 
    switch (string[j])
    {
    case 'a': count++; break;
    case 'e': count++; break;
    case 'i': count++; break;
    case 'o': count++; break;
    case 'u': count++; break;
    }
    }
    cout<<"There are "<<count<<" Vovels"<<endl;
    }
     
    Jul 8, 2007
    1,138
    156
    0
    Melbourne
    ¤--bACarDi--¤ said:
    Machan meken count wenne vowel sounds nemei vowel letters....k
    Awlak thiyenawanam kiyapan....;)

    Code:
    #include <iostream>
    using namespace std;
    int main ()
    {
    char string[25];
    int count=0;
    cout<<"Enter String:";
    cin>>string;
    
    for (int j=0;j<26;j++)
    { 
    switch (string[j])
    {
    case 'a': count++; break;
    case 'e': count++; break;
    case 'i': count++; break;
    case 'o': count++; break;
    case 'u': count++; break;
    }
    }
    cout<<"There are "<<count<<" Vovels"<<endl;
    }


    machan meken wenne enter karana sentence eke first word eke no. of vowels print wena eka witharai. always the vowels in the first word.

    E.g: " Investigation is successful"
    it prints "There are 6 vowels.

    Only the first word. How to calculate the no.of vowels in the whole sentence?
    I think we have to separate each word into one subscript in the array
    array[1]=Investigation
    array[2]=is
    array[3]=successful

    and then calculate the no.of vowels in each word and then output the total no. of vowels in the whole sentence, how to do this.
     

    ¤--bACarDi--¤

    Well-known member
  • Jan 9, 2009
    12,130
    288
    83
    124.43.xxx.xxx
    chinthakapathir said:
    machan meken wenne enter karana sentence eke first word eke no. of vowels print wena eka witharai. always the vowels in the first word.

    E.g: " Investigation is successful"
    it prints "There are 6 vowels.

    Only the first word. How to calculate the no.of vowels in the whole sentence?
    I think we have to separate each word into one subscript in the array
    array[1]=Investigation
    array[2]=is
    array[3]=successful

    and then calculate the no.of vowels in each word and then output the total no. of vowels in the whole sentence, how to do this.

    Code:
    #include <iostream>
    
    using namespace std;
    int main ()
    {
    char string[50];
    int count=0;
    cout<<"Enter String:";
    cin.get(string,50);
    
    for (int j=0;j<51;j++)
    { 
    switch (string[j])
    {
    case 'a': count++; break;
    case 'e': count++; break;
    case 'i': count++; break;
    case 'o': count++; break;
    case 'u': count++; break;
    }
    }
    cout<<"There are "<<count<<" Vovels"<<endl;
    }
    Try this...!!! :D :P ;)
     
    Jul 8, 2007
    1,138
    156
    0
    Melbourne
    ¤--bACarDi--¤ said:
    Code:
    #include <iostream>
    
    using namespace std;
    int main ()
    {
    char string[50];
    int count=0;
    cout<<"Enter String:";
    cin.get(string,50);
    
    for (int j=0;j<51;j++)
    { 
    switch (string[j])
    {
    case 'a': count++; break;
    case 'e': count++; break;
    case 'i': count++; break;
    case 'o': count++; break;
    case 'u': count++; break;
    }
    }
    cout<<"There are "<<count<<" Vovels"<<endl;
    }
    Try this...!!! :D :P ;)

    elakiri boss meka wada gindara wage. thank you sooo sooo much man. needed this so much. thanks. ;) :lol:
     

    ¤--bACarDi--¤

    Well-known member
  • Jan 9, 2009
    12,130
    288
    83
    124.43.xxx.xxx
    chinthakapathir said:
    elakiri boss meka wada gindara wage. thank you sooo sooo much man. needed this so much. thanks. ;) :lol:

    Ow machan matath keywords amathaka wela thibbe.....Elai kaL giye.....
    One help ekak illapan.... Puluwan widiyata sup eka dennam....;) :)
     
    Jul 8, 2007
    1,138
    156
    0
    Melbourne
    ¤--bACarDi--¤ said:
    Ow machan matath keywords amathaka wela thibbe.....Elai kaL giye.....
    One help ekak illapan.... Puluwan widiyata sup eka dennam....;) :)

    ela kiri machan thanks again.

    Issarahatath deffa umbe help one wei. hehe thanks again man.;) :cool::lol: