Skip to content

Instantly share code, notes, and snippets.

@eebssk1
Created September 14, 2017 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eebssk1/478f343a3c666496a43c34269ebe6404 to your computer and use it in GitHub Desktop.
Save eebssk1/478f343a3c666496a43c34269ebe6404 to your computer and use it in GitHub Desktop.
emmm
#include<iostream>
#include<sstream>
using namespace std;
bool myisdigit(string str)
{
for(int i=0;i<str.size();i++)
{
if ((str.at(i)>'9') || (str.at(i)<'0') )
{
return false;
} else {
return true;
}
}
}
int myfunc() {
int r;
string i,s,bii;
stringstream ii,ss;
int b,c;
cout << "Enter a number:" << endl;
cin >> i;
ii.clear();
ii.str(i);
cout << "Enter a square:" << endl;
cin >> s;
ss.clear();
ss.str(s);
if (!myisdigit(i) || !myisdigit(s)) {
cout << "Not Numbers!" << endl;
return (-1);
}
ii >> r;
ss >> b;
for(c=1;c<=b-1;c++) {
r = r * r;
}
bii = to_string(r);
cout << "result is " + bii << endl;
return r;
}
int main() {
int re;
do {
re = myfunc();
if (re != 0)
re = 0;
} while (re == 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment