anyway here's the code any help is greatly appreciated
#include <iostream>
#include <cctype>
using namespace std;
int main()
{
double myInt;
char myStr[30];
int i,len;
bool validData;
do
{
cout << "Enter a number: ";
gets (myStr);
validData = true;
len = strlen(myStr);
i = 0;
while ((i < len) && (validData == true))
{
if (i == 0)
{
if (isdigit(myStr[30]))
{
validData = false;
}
}
else
{
validData = false;
}
i++;
}
if (validData == true)
{
myInt = atof(myStr);
cout << "Twice the value entered is: " << myInt*2 << endl;
}
else
{
cout << "Incorrect Data. Try again!!! \n";
}
} while (validData == false);
return 0;
}

New Topic/Question
Reply




MultiQuote




|