In: Computer Science
Draft a program that scans an alphanumeric array to determine the first alphabet in the array. If found, the program should print “alphabet found” its value and index. If no alphabet is found, the program should print “no alphabet found.” Submit the asm/list file and screenshots that show the output of your code for the following example arrays:
a. Array has only alphabets
b. Array has only numerals
c. Several arrays with a mix of alphabets and numerals positioned at different indices
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int n=s.length();
int flag=0;
for(int i=0;i<n;i++){
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
{
cout<<endl;
cout<<"output:"<<endl;
cout<<"Alphabet Found"<<endl;
cout<<"Value="<<s[i]<<endl;
cout<<"Index="<<i<<endl;
flag=1;
break;
}
}
if(flag==0)
{
cout<<endl;
cout<<"output:"<<endl;
cout<<"no alphabet found";
}
return 0;
}
a. Array has only alphabets:
b. Array has only numerals:
c. Several arrays with a mix of alphabets and numerals positioned at different indices: