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 =...
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
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.
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...
Each of the first 6 letters of the alphabet is printed on a separate card. The...
Each of the first 6 letters of the alphabet is printed on a separate card. The letter “a” is printed twice. What is the probability of drawing 4 cards and getting the letters f, a, d, a in that order? Same question if the order does not matter.
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT