Biocomputer
24-07-2003, 06:16 PM
hi
i have a problem with this example it is about a looping
======
An identifier in c++ is a word that contains one or more characters such that :
the first character is a letter or '_'
tge rest of the characters consist of letters digits and \or'_'
writ a program that keeps reading word from the user and for each word ther program indicates if the word is an identifier or not . the user should end each word with the character "<" and will terminate when it reads"#" as the first character in the word (assuming "<" will be used only at the end of word
i tried to solve the problem i dont know :(
=========================
#include <iostream>
using namespace std;
char n;
bool p=(n=='_');
bool pa=(n>='a')&& (n<='z');
bool pA=(n>='A')&& (n<='Z');
bool pD=(n>='1')&&(n<='9');
int main()
{
cout<<"please enter a set of words each word ending with '!' and '#'marking the end of the input"<<endl;
cin.get(n);
if (p||pa||pA)
{
do
{
cin.get(n);
}while(!p||!pa||!pA||!pD);
if (n=='!')
cout<<"it is an indentifier";
else
cout<<"it is NOT indentifier";
}
else
cout<<"it is NOT indentifier";
return 0;
}
===========
thax for helping
my email
q8wizard8@homail.com
i have a problem with this example it is about a looping
======
An identifier in c++ is a word that contains one or more characters such that :
the first character is a letter or '_'
tge rest of the characters consist of letters digits and \or'_'
writ a program that keeps reading word from the user and for each word ther program indicates if the word is an identifier or not . the user should end each word with the character "<" and will terminate when it reads"#" as the first character in the word (assuming "<" will be used only at the end of word
i tried to solve the problem i dont know :(
=========================
#include <iostream>
using namespace std;
char n;
bool p=(n=='_');
bool pa=(n>='a')&& (n<='z');
bool pA=(n>='A')&& (n<='Z');
bool pD=(n>='1')&&(n<='9');
int main()
{
cout<<"please enter a set of words each word ending with '!' and '#'marking the end of the input"<<endl;
cin.get(n);
if (p||pa||pA)
{
do
{
cin.get(n);
}while(!p||!pa||!pA||!pD);
if (n=='!')
cout<<"it is an indentifier";
else
cout<<"it is NOT indentifier";
}
else
cout<<"it is NOT indentifier";
return 0;
}
===========
thax for helping
my email
q8wizard8@homail.com