Question

In: Computer Science

Draft a program that scans an alphanumeric array to determine the first alphabet in the array.  If...

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

Solutions

Expert Solution

#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:


Related Solutions

Theory of computation: Consider the alphanumeric alphabet Σ = {a, b, . . . , z,...
Theory of computation: Consider the alphanumeric alphabet Σ = {a, b, . . . , z, A, B, . . . , Z, 0, 1, . . . , 9} and let L be the language of all regular expressions over Σ: L = {w ∈ Σ ∪ {∅,(,), ∪, ·, * }* | w is a syntactically legal regular expression over Σ} Give an unambiguous context-free grammar that generates L. The grammar should use the following precedence levels, from...
/** * This program will sort an n by n array by the first value in...
/** * This program will sort an n by n array by the first value in each row. * Selection sort algorithm is modified to do the sorting. * For example: * <p/> * If the original array is: * 1 2 3 4 5 * 3 4 5 1 2 * 5 2 3 4 1 * 2 3 1 4 5 * 4 2 3 1 5 * <p/> * The array after sorting is: * 1 2...
Write a C program that loops and asks a user to enter a an alphanumeric phone...
Write a C program that loops and asks a user to enter a an alphanumeric phone number and converts it to a numeric one. No +1 at the beginning. You can put all code in one quiz1.c file or put all functions except main in phone.c and phone.h and include it in quiz1.c Submit your *.c and .h files or zipped project */ #pragma warning (disable: 4996) //windows #include <stdio.h> #include <string.h> #include <stdbool.h> #include <ctype.h> enum { MaxLine =...
Write a C++ function that lets the user enter alphabet letters into a static char array...
Write a C++ function that lets the user enter alphabet letters into a static char array until either the user enters a non-alphabet letter or, it has reached the MAXSIZE. You can use the isalpha([Char]) function to check if the input is an alphabet letter or not. void fillArray (char ar[], size_t& size){ // this is the function prototype }
1. Create a PHP program containing an multi dimensional array of all the first and last...
1. Create a PHP program containing an multi dimensional array of all the first and last names of the students in your class. Sort the array by last name in alphabetic order. Also sort the array in reverse order. 2. Split the array from #1 into two arrays; one containing first names, the other containing last names.
Given a security code for door access consists of 4 alphanumeric characters, and the first character...
Given a security code for door access consists of 4 alphanumeric characters, and the first character has to be a letter. Determine the proportion of security code that: is a unique code                                                                                          begin with a vowel (a, e, i, o, u)                                                                  end with odd number (1, 3, 5, 7, 9) begin with a vowel and end with odd number                 
Submit a draft of the first section of your Economics Module Assignment. While a “draft” your...
Submit a draft of the first section of your Economics Module Assignment. While a “draft” your submission, it must be in paragraph form, properly formatted and proofread thoroughly. I expect your draft response to each topic to be between one half and one page long. 1. INCENTIVES TO BUY HYBRID VEHICLES 2.DON’T FORGET THE COSTS OF TIME AND INVESTED FUNDS 3.LAW OF DEMAND FOR YOUNG SMOKERS
create a file with 1000 alphanumeric ones written one per line. Write a program in python...
create a file with 1000 alphanumeric ones written one per line. Write a program in python that randomly selects 100 of them, holds the index of each alphanumeric, adds the hash of the previous 100 and tries to find a random alphanumeric so that if it adds it to the list of indicators the SHA256 of the whole to have 10 zeros at the end. You start with the original Hash: 1111..111 my solution so far: import random import string...
Write a program that uses a dictionary to assign “codes” to each letter of the alphabet....
Write a program that uses a dictionary to assign “codes” to each letter of the alphabet. For example:      codes = {'A':'%', 'a':'9', 'B':'@', 'b':'#', etc....} Using this example, the letter “A” would be assigned the symbol %, the letter “a” would be assigned the number 9, the letter “B” would be assigned the symbol “@” and so forth. The program should open a specified text file, read its contents, and then use the dictionary to write an encrypted version of...
ASSIGNMENT: Write a program to reverse an array and then find the average of array elements....
ASSIGNMENT: Write a program to reverse an array and then find the average of array elements. Start by creating 2 arrays that can each hold 10 integer values. Then, get values from the user and populate the 1st array. Next, populate the 2nd array with the values from the 1st array in reverse order. Then, average the corresponding elements in the 1st and 2nd arrays to populate a 3rd array (average the 1st element of the 1st array with the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT