Read the additional info for what I need thank you!
#include %26lt;iostream%26gt;
#include %26lt;string%26gt;
using namespace std;
int temp;
int main()
{
int numbers[5];
int counter;
string str;
cout %26lt;%26lt;" Welcome!";
cout %26lt;%26lt;"Please enter 5 numbers with spaces in between: ";
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;"\nEnter 5 words: "%26lt;%26lt;endl;
while (counter %26lt; 4)
{
cout %26lt;%26lt; "Enter word "%26lt;%26lt;counter + 2%26lt;%26lt;" :";
cin %26gt;%26gt;str;
cout%26lt;%26lt;"First Letter of Your Word is: "%26lt;%26lt;str[0]%26lt;%26lt;" and the third letter is: "%26lt;%26lt;str[2]%26lt;%26lt;endl;
counter++;
}
return 0;
}
Need a programmers help with my C++ Program?
to read to and from a file, you need
#include%26lt;fstream%26gt;
then define the file you want to read to as an "ofstream" type:
ofstream output_example("output_file.txt");
so instead of
cout%26lt;%26lt;.....
now you want to write
output_example%26lt;%26lt;.......%26lt;%26lt;endl;
and so on- this will write your numbers to a file named output_file.txt
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment