1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
DedPeter [7]
3 years ago
7

The intention of this problem is to analyze a user input word, and display the letter that it starts with (book → B).

Computers and Technology
1 answer:
yulyashka [42]3 years ago
3 0

Answer:

Here is the C++ program:

#include<iostream>  // to use input output functions

using namespace std;     //to identify objects like cin cout

void StartChar(string str)  {  // function that takes a word string as parameter and returns the first letter of that word in capital

   int i;  

   char c;

   do  //start of do while loop

   {

   for (int i = 0; i < str.length(); i++) {  //iterates through each character of the word str

       if(str.length()>25){  //checks if the length of input word is greater than 25

           cout<<"limit exceeded"; }  //displays this message if a word is more than 25 characters long

      c = str.at(i);   // returns the character at position i

       if (! ( ( c >= 'a' && c <= 'z' ) || ( c >= 'A' && c <= 'Z' ) ) ) {  //checks if the input word is contains characters other than the alphabet

            cout<<str<<" is not a word!"<<endl; break;}  //displays this message if user enters characters other than the alphabet

        if (i == 0) {  //check the first character of the input word

           str[i]=toupper(str[i]);  //converts the first character of the input word to uppercase

           cout<<str<<" starts with letter "<<str[i]<<endl;  }  // prints the letter that the word starts with in capital letter

   }   cout<<"Enter a word: ";  //prompts user to enter a word

      cin>>str;   //reads input word from user

}while(str!="#");   }    //keeps prompting user to enter a word until the user enters #

int main()   //start of the main() function body

{ string str;  //declares a variable to hold a word

cout<<"Enter a word: "; //prompts user to enter a word

cin>>str; //reads input word from user

   StartChar(str); }  //calls function passing the word to it

     

Explanation:

The program prompts the user to enter a word and then calls StartChar(str) method by passing the word to the function.

The function StartChar() takes that word string as argument.

do while loop starts. The for loop inside do while loop iterates through each character of the word string.

First if condition checks if the length of the input word is greater than 25 using length() method which returns the length of the str. For example user inputs "aaaaaaaaaaaaaaaaaaaaaaaaaaa". Then the message limit exceeded is printed on the screen if this if condition evaluates to true.

second if condition checks if the user enters anything except the alphabet character to form a  word. For example user $500. If this condition evaluates to true then the message $500 is not a word! is printed on the screen.

Third if condition checks if the first character of input word, convert that character to capital using toupper() method and prints the first letter of the str word in capital. For example if input word is "Computer" then this prints the message: Computer starts with the letter C in the output screen.

The program keeps prompting the user to enter the word until the user enters a hash # to end the program.

The output of the program is attached.

You might be interested in
Which two statements describe the Functions of a modem
cupoosta [38]

Answer:

A modem is the internal or external device its function is to transfer data over communication lines

modems use two different types of data transmission

synchronous and asynchronous

The functions of modem have changed over years it was first used for telegrams and to transmit data in 1950s.

Modems were used with computers in  1977 for first time to transmit data between computers  firstly it was used for small amount of computers

As modem improves day by day and were able to transmit information fastly between two or more hosts and the internet network slowly spreads

There are four types of modems ,

1 Fax Modems which solely transfer data between fax machines

2 The traditional ISDN modem

3 the Digital Subscribers Line

4 the Cable Modem

Explanation:

3 0
3 years ago
You work as the IT security administrator for a small corporate network. You have designed the physical security of the offices
ladessa [460]

The security IT administrator he or she is planning to install smart card communications over the network which is can be access through TCP IP address.

Smart card key reader to be placed or installed where is required  such as an opening door  or entrance of office or organization extra.

Key card readers should be contactless and record more volume of data and it should synchized with the system at regular intervals.

By Installing smart card and it readers unauthorized  person entry to lab or network server can be avoided. Since smart card reader connected to the network, IT SECURITY administrator can generate log reports.

5 0
3 years ago
What is the full form of ms-word?​
Alex

Answer:

microsoft word

Explanation:

i got certified on it sooooooooooo...

6 0
3 years ago
Read 2 more answers
In what type of attack does the adversary leverage a position on a guest operating system to gain access to hardware resources a
il63 [147K]

Answer:

VM escape attack

Explanation:

<em>In a VM escape attack, the attacker exploits hypervisor vulnerabilities to gain control over resources reserved for other guest operating systems. Services operating on the guest may be exposed to the other attacks, but such attacks can only access data allotted to the same guest. In the event of a buffer overflow or directory traversal or the client in the case of cross-site scripting.</em>

6 0
2 years ago
What is a variable? Why is it helpful in programming?
Komok [63]

Answer:

Variables can represent numeric values, characters, character strings, or memory addresses. Variables play an important role in computer programming because they enable programmers to write flexible programs. Rather than entering data directly into a program, a programmer can use variables to represent the data.

Explanation:

3 0
3 years ago
Other questions:
  • A ____ is text and graphics that print at the bottom of every page.
    12·1 answer
  • Which of the following is the final fate for average sized stars?
    12·1 answer
  • why backupdocs.com keeps giving computer system update with regards to pdf documents savings? #backupdocuments
    6·1 answer
  • Write a program that assigns two integer values from standard input to the variables int1 and int2, then prints "True" if they a
    10·1 answer
  • What is the full form of ICT?​
    14·2 answers
  • Select the pieces of information that are added on to data to get it where it is going.
    5·1 answer
  • What are attributes and what role do they play with in a HTML document?
    11·1 answer
  • A website for a certain political party or candidate is likely to have unbiased
    6·1 answer
  • You can use _____ to track the state of each user in the application.
    8·1 answer
  • Select the correct answer.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!