So I have a homework
I have to write a program which will test if an integer is a three digit number or not (I obviously have to use IF) and if it is, it should write it in reversed form. (from 123 to 321)
and also
printing should happen in file "sample.txt" ( I don't know what this means O_o)
I know that second part (reversed number) is like this
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string num;
cout << "Please enter an integer: ";
getline(cin, num);
if(num.size() == 3)
{
cout << "The number is 3 digits long " << endl;
cout << "The number in reverse is ";
string::reverse_iterator it;
for (it = num.rbegin(); it < num.rend(); it++)
cout << *it;
cout << endl;
}
else
cout << "The number does not contain 3 digits";
cin.ignore();
return 0;
}