Help with array question

So I'm trying to write a loop that displays the characters in a string message in reverse order and then I need to write a function "scalarMultArray" that multiplies an entire floating-point array x (consisting of n elements) by a single floating-point scalar c. Array x should be used for input/output.
I have no idea how to do this. I'm not knowledgable in arrays. Anyone can help? I have a program that needs to have these to functions in side of them and I'm not sure how to do them. Thank you for any help.
Last edited on
When your array is called a, you get the element at index i with a[i]. That's all you need to know about arrays in order to complete this task.
you need the length of the string

start from the length

loop and print the characters until i = 0
Last edited on
I would use iterators like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>
#include <iterator>

using namespace std;

int main()
{
  string word;
  cout << "Enter a word: ";
  cin >> word;
  cout << word << " Word is :  ";
  copy(word.rbegin(), word.rend(), ostream_iterator<char>(cout));
  cout << " reversed" << std::endl;
}
Last edited on
alright thanks a lot
Topic archived. No new replies allowed.