HELP!!!!

Can someone make a program that
accepts a word into a chracter array string variable. Display a
count of the number of letters in the word. Also display a count of the number of the vowels and the number of consonants in the word

and then put comment code on it and explain it to me
closed account (z05DSL3A)
You are unlikely to get anyone to do your course work for you, if you have a specific question about a problem then post it, preferably with source code. If you show that you are trying to do the work people are more likely to help!
Its not actually course work it was a bonus assignment and I need to get an Idea on how to even start this off because I have never encountered anything this complex using C++ I am still just learning about strings and classes and would like to get an understanding of this work.
Maybe if you defined it better we could help you get started...what is a "character array string"??
A string or a Character array that acts like a string.
Just another question...
What is the difference between global and local variables...
I have no Idea... ><
Put simply, gloabal variables can be used anywhere in your program, while local varaibles can only be used in the function they are declared in.
C++ make this more complicated as varaibles can be declared where you need them, rather than just at the start of a function
so you can have
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int a;           //Global variable
int myfunction(int b)
{
    int c=5;               //local variable
    return (b*c+a);
}
 int main();
{
   int d=10;            //local variable, anywhere in main
   a = 2;
   for (int i=0; i<d; i++)    //i is local to the for loop only
   {
        cout << myfunction(i) << endl;
   }
   return 0;
}

You cannot reference d or i in myfunction as they are local to main, similarly you cannot reference c in main.
i is an example of a varaible which is local to just a simple block of code (in this case a for loop).
b is local to myfunction, but takes the value of i (in this case) each time the function is called in the loop.
Last edited on
Shadow:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Pseudo code only, for the "concept" of how to do this
#include <iostream>
#include <string>

char alphabet[26];

int main()
{
  // Initialize the alphabet
  for (int i = 0; i < 26; i++)
    alphabet[i] = 'a' + i;         // Set the alphabet array to contain 'a..z' 

  // Type "string" is used because it will increase in size automatically
  std::string userInput;

  // For this example only, assume that ALL text entered are lowercase, and without punctuation.
  std::cout << "Input the string of text: ";
  std::cin >> userInput;

  unsigned int inputSize = userInput.size();

  std::cout << "The size of the entire string (including spaces, punctuation, etc.) is: "
            << inputSize << std::endl;

  unsigned int letterCount = 0;
  for (int i = 0; i < inputSize; i++)
  {
    if (userInput[i] >= 'a' && userInput[i] <= 'z')
      letterCount++;
  }

  std::cout << "The number of letters counted (lowercase, for this example) is: "
            << letterCount << std::endl;

  unsigned int vowelCount = 0;
  for (int i = 0; i < inputSize; i++)
  {
    if (userInput[i] == 'a' || userInput[i] == 'e' || userInput[i] == 'i' ||
        userInput[i] == 'o' || userInput[i] == 'u')
    {
      vowelCount++;
    }
  }

  // ... and so on, and so forth ...

}
Thanks
Could you give me an example of a program that uses 1 function and 2 logical structures.

Here is a project i was working on that you would enter parts of a code to get a specific part of a companys items but along the way I got lost...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<iostream>
#include<string>
using namespace std;
int main()
{
char character1, character4; 
int character2, character3, character5, character6; 

cout<<"Enter a character must be A, B, or C"<<endl;
cout<<""<<endl;
cin>>character1;


if ( character1 != 'A' || 'B' || 'C')
{
cout<<"You entered an incorrect character please enter again..."<<endl;
cout<<""<<endl;
cin>>character1;
}


cout<<"Enter a number that can add up with a second number"<<endl
<<"To equal at least 22 and no more than 66"<<endl;
cout<<""<<endl;
cin>>character2;
cin>>character3;

if ( character2 + character3 < 22 )
{
cout<<"Your numbers equal less than 22 please enter another set"<<endl
<<"That combined equals more than 22 and less than 66"<<endl;
cout<<""<<endl;
cin>>character2;
cin>>character3;
}
if (character2 + character3 > 66 )
{
cout<<"Your numbers equal more than 66 please enter another set"<<endl
<<"That combined equals more than 22 and less than 66"<<endl
<<""<<endl;
cin>>character2;
cin>>character3;
}

cout<<"Enter a character that must be lower case"<<endl
<<""<<endl;
cin>>character4;

if ( character4 = 'A' || 'B' || 'C' || 'D' || 'E' || 'F' || 'G' || 'H' || 'I' || 'J' || 'K' || 'L' || 'M' || 'N' || 'O' || 'P' || 'Q' || 'R' || 'S' || 'T' || 'U' || 'V' || 'W' || 'X' || 'Y' || 'Z' ) 
{
cout<<"You entered a capitalized letter please enter a letter that is lower case"<<endl;
cout<<""<<endl;
cin>>character4;
}     

  system("PAUSE");
  return 0;

}
try out kasamba. google it. you can hire a programmer to do one time stuff for you
Topic archived. No new replies allowed.