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 program that will search through an array and check to see if the first...
Write a program that will search through an array and check to see if the first number in the array occurs more than once. If the first number occurs more than once, return true. Otherwise, return false. If the array is empty, return false? You will need to use a variable, loop, and if statement.
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 =...
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
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                 
In C programming, Thanks Write a program to determine which numbers in an array are inside...
In C programming, Thanks Write a program to determine which numbers in an array are inside a particular range. The limits of the range are inclusive. You have to write a complete "C" Program that compiles and runs in Codeblocks. (main.c) 1. Declare an array that can contain 5 integer numbers. Use as the name of the array your LastName. 2. Use a for loop to ask the user for numbers and fill up the array using those numbers. 3....
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 }
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.
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT