Hello folks,
im creating a program, that checks whether a number is a Neon Number (a number where the digits of the square of the number are equal to the number itself so for example 9*9 = 81, 8+1 = 9). Im creating an int, asking user for input and wanna convert it to string now. The errors I get are the following (Visual Studio 2015)
to_string is not a member of "std"
to_string identifier not found
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <string>
#include "stdafx.h"
#include <iostream>
using std::cout;
using std::cin;
using std::string;
int main()
{
std::cout << "NEON NUMBER TESTER \n enter your number \n";
int number;
cin >> number;
string numberstr = std::to_string(number);
int firstnr = numberstr[0];
cout << firstnr;
cin.get();
}
#include <iostream>
#include <algorithm>
#include <numeric>
usingnamespace std;
bool is_neon(int num, int square_root)
{
int sum = 0;
while (num > 0)
{
sum += (num % 10);
num = num / 10;
}
return sum == square_root;
}
int main()
{
for (int num = 2; num < 1000000; num++)
{
if (is_neon(num * num, num))
{
cout << "Neon number: " << num * num << "\n";
}
}
return 0;
}