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
DanielleElmas [232]
4 years ago
14

5.15 LAB: Count input length without spaces, periods, or commas Given a line of text as input, output the number of characters e

xcluding spaces, periods, or commas. Ex: If the input is:
Computers and Technology
2 answers:
strojnjashka [21]4 years ago
7 0

Answer:

Following are the code to this question:

userVal = input()#defining a variable userVal for input the value

x= 0#defining variable x that holds a value 0

for j in userVal:#defining for loop to count input value in number

   if not(j in " .,"):#defining if block that checks there is no spaces,periods,and commas in the value

       x += 1#increment the value of x by 1

print(x)#Print x variable value

Output:

Hello, My name is Alex.

17

Explanation:

In the above-given code, a variable "userVal" is defined that uses the input method for input the value from the user end, in the next line, an integer  variable "x" is defined, hold value, that is 0, in this variable, we count all values.

  • In the next line, for loop is defined that counts string value in number and inside the loop an if block is defined, that uses the not method to remove spaces, periods, and commas from the value and increment the value of x by 1.
  • In the last step, the print method is used, which prints the calculated value of the "x" variable.    

 

Vlad1618 [11]4 years ago
6 0

Answer:

Explanation:#include <iostream>

#include<string>

using namespace std;

int main()

{

  string str;

   

cout<<"Enter String \n";

 

getline(cin,str);/* getLine() function get the complete lines, however, if you are getting string without this function, you may lose date after space*/

 

  //cin>>str;

 

  int count = 0;// count the number of characeter

  for (int i = 1; i <= str.size(); i++)//go through one by one character

  {

     

   

   if ((str[i]!=32)&&(str[i]!=44)&&(str[i]!=46))//do not count  period, comma or space

{

          ++ count;//count the number of character

      }

  }

  cout << "Number of characters are  = "; //display

cout << count;// total number of character in string.

  return 0;

}

}

You might be interested in
A software architecture that divides an application into view, business logic, and data is called a(n) ________.â
Leokris [45]
Software architecture divides an application into views
4 0
4 years ago
Which describes the purpose of the continue statement in Java?
Anton [14]
Your answer is d skip to the next line



7 0
3 years ago
Which feature helps an edit-test-bug cycle work faster in the python programming language
pochemuha

Answer:

Since there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python programs is easy: a bug or bad input will never cause a segmentation fault. Instead, when the interpreter discovers an error, it raises an exception.

Explanation:

3 0
3 years ago
Read 2 more answers
Give the 16-bit 2's complement form of the following 8-bit 2's complement numbers: (a) OX94 (b) OXFF (c) OX23 (d) OXBCWhich of t
Korvikt [17]

Answer:

Answer is provided in the explanation section

Explanation:

Convert 8-bit 2’s complement form into 16-bit 2’s complement form.

First write value in binary then check for 8 th bit value. If it is positive the upper 8 bits will  be zero otherwise will be 1s.

8-bit number   Binary of number    Insert 8 bits                  16-bit number

0X94                1001-0100                 1111-1111-1001-0100            0XFF94

0XFF                1111-1111                       1111-1111-1111-1111                 0XFFFF

0X23                0010-0011                 0000-0000-0010-0011    0X0023

0XBC               1011-1100                    1111-1111-1011-1100              0XFFBC

Which of the following 16-bit 2’s complement form can be shortened to 8-bits?

16-bit number        8-bit number

0X00BA                  0XBA

0XFF94                   MSB bits are not zero so we can’t  truncate it to 8-bit No

0X0024                  0X24

0XFF3C                   MSB bits are not zero so we can’t  truncate it to 8-bit No

4 0
3 years ago
The _______ is a small program run by a computer when first powered on. its primary function is to stabilize the machine and dev
tigry1 [53]
Hello <span>TheCelloAlex1645 </span>

Answer: <span>The BIOS is a small program run by a computer when first powered on. its primary function is to stabilize the machine and devices on the motherboard so that the operating system can be loaded and take control of the computer.


Hope this helps
-Chris</span>
3 0
4 years ago
Other questions:
  • Do all accounts use the same routing number
    12·1 answer
  • Jamie works on a spread sheet in which he has to label stes of data. How can he navigate between the cells in the spread sheet
    8·1 answer
  • Which of the following is NOT a logical operator (logical connective)?
    5·1 answer
  • you are configuring a firewall to all access to a server hosted in the demilitarized zone of your network. You open IP ports 80,
    7·1 answer
  • Organizational Units are typically configured to: prevent companies from sharing resources. ensure that the system password is t
    13·1 answer
  • The weight of your car will also affect its_____.
    13·2 answers
  • --------------------------------------------------------------------------------------------------------------------------------
    8·1 answer
  • select the correct answer from each drop-down menu. “To clean a computer screen, use ___. To clean a keyboard, use a ___.”
    7·1 answer
  • Which type of file can be opened directly into Excel?
    15·1 answer
  • Need comments added to the following java code:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!