السلام عليكم ،
المسئلة :
whrite a c++ program that asks the user to input unknown number of characters terminated '#' character. your program should count the number o alphabets (a-z ,A-Z) and the number of non-alphabets in the giving input.
ال output يكون بهذا الشكل :
Enter characters terminated by '#'
IT123#
Number of alphabet is 2
Number of non-alphabet is 3
انا كتبت هذا الكود ، الكود ما في خطأ ، بس لما اشغل البرنامج يطلع لي مكان عدد الحروف و عدد غير الحروف رموز غريبة :S
# include <iostream>
using namespace std ;
int main ()
{
char ch , cha = 0 , chNon = 0 ;
cout << " Enter characters terminated by # :" << endl ;
cin >> ch ;
while (ch != '#')
{
if ( ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 )
++cha ;
else ++chNon ;
cin >> ch ;
}
cout << "Number of alphabets is" << cha << endl;
cout << "Number of non-alphabets is" << chNon << endl;
return 0 ;
}
هل المشكلة في طريقة حلي للكود او الكود صح بس في مشكلة ؟