Need tutorial on writing this program please

I have to do this program on Visual studio. Some help would be appreciated please:

Write a program that prompts the user to input a four-digit positive integer. The program then outputs the digits of the number, one digit per line. For example , if the input is 3245, the output is:
3
2
4
5
What have you written so far?
I tried to do it, but it has given me an error. Can someone please help me how to write this code on Microsoft visual studio?
Post what you tried and copy and paste the exact error message.
int[] GetIntArray(int num)
{
List<int> listOfInts = new List<int>();
while(num > 0)
{
listOfInts.Add(num % 10);
num = num / 10;
}
listOfInts.Reverse();
return listOfInts.ToArray();
}


It gave me lots of errors.
closed account (48T7M4Gy)
You don't need listOfInts.

Just store each digit in GetIntArray then cout the contents in reverse order using a for loop.

To initialise GetIntArray your first line should be:
int GetIntArray[4];
Won't this work??
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

int main()
{
    int n = 4;
    char a[n+1];//Create an extra space to store the null character at the end
    std::cout<<"Enter a "<<n<<" digit number: ";
    std::cin.get(a,n+1);
    for(int i=0;i<n+1;i++)
    {
        std::cout<<a[i]<<"\n";
    }
    return 0;
}

Topic archived. No new replies allowed.