I wrote a program that prompts the user to enter a four digit positive integer. What I need is the program to output the four digit integer one digit on one line at a time. For example if the output is 4444:
4
4
4
4
#include <stdio.h> // C standard input/output library
int main()
{
printf("Please enter a four digit number: "); // prompt the user to enter a number
char input[4]; // create a new array of characters
scanf("%s",&input); // get four numbers into input
printf("%c\n%c\n%c\n%c\n",input[0],input[1],input[2],input[3]); // output each character on a different line
fflush(stdin); // flush stdin
getchar(); // wait for user to press enter, so they see the output
return 0; // exit program
}
C++:
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream> // C++ input/output library
usingnamespace std; // std namespace functions being used
int main()
{
cout<<"Please enter a four digit number: "; // prompt the user to enter a number
char input[4]; // create a new array of characters
cin>>input; // get four numbers into input
cout<<input[0]<<endl<<input[1]<<endl<<input[2]<<endl<<input[3]; // output each character on a different line
fflush(stdin); // flush stdin
cin.get(); // wait for user to press etner, so they see the output
return 0; // exit program
}