here is my code :
#include %26lt;iostream%26gt;
#include %26lt;string%26gt;
using namespace std;
int temp;
int main()
{
int numbers[5];
int counter;
char list[6][16];
cout %26lt;%26lt;"Please enter 5 numbers: ";
for (counter = 0; counter %26lt; 5; counter++)
{
cin %26gt;%26gt; numbers[counter];
}
cout %26lt;%26lt; endl;
cout %26lt;%26lt;" The numbers in reverse order are: ";
for (counter = 4; counter %26gt;=0; counter--)
cout %26lt;%26lt; numbers[counter] %26lt;%26lt; " ";
cout %26lt;%26lt; endl;
cout %26lt;%26lt;"Enter 5 words: ";
for (temp = 0; temp%26lt;6; temp++)
{
cin.get (list[temp],16);
}
cout %26lt;%26lt; list %26lt;%26lt; endl;
return 0;
}
I need to be able to take 5 words and then display the 1st and 3rd letter of each word...im stumped...please help
the words need to be stored into a string array just cant figure out how need the extra help thanks
C++ program help!?
Since your list is a two dimensional array of type char you need only to print out something like
cout %26lt;%26lt; list[temp][1] %26lt;%26lt; list[temp][3] %26lt;%26lt; endl;
in a for loop like you have done before.
If you were using true string variables then you might have had more trouble but, even so, string variables have a method for exporting to character arrays anyway.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment