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
madreJ [45]
3 years ago
6

Write a function that converts a string into an int. Assume the int is between 10 and 99. Do not use the atoi() or the stoi() fu

nction.
Computers and Technology
1 answer:
Liula [17]3 years ago
6 0

Answer:

Written in C++

#include <iostream>

#include <sstream>

using namespace std;

int main()  {

   string num;

   cout<<"Enter a number: ";

   cin>>num;

   stringstream sstream(num);

   int convertnum = 0;

   sstream >> convertnum;

   cout << "Output: " << convertnum;

}

Explanation:

Without using atoi() or stoi(), we can make use of a string stream and this is explained as follows:

This line declares a string variable num

   string num;

This line prompts user for input

   cout<<"Enter a number: ";

This line gets user input

   cin>>num;

This line declares a string stream variable, sstream

   stringstream sstream(num);

This line declares and initializes the output variable, convertnum to 0

   int convertnum = 0;

The stream is passed into the output variable, convertnum

   sstream >> convertnum;

This line displays the output

   cout << "Output: " << convertnum;

<em>Note that: if user enters a non integer character such as (alphabet, etc), only the integer part will be convert.</em>

<em>For instance,</em>

<em>40a will be outputted as 40</em>

You might be interested in
Laura is in the middle of making a presentation. On one slide, she includes a heading, three subheadings, and three bullet point
kati45 [8]
Make them different colors & bold it out.
8 0
3 years ago
What is computer ????
LekaFEV [45]

Answer:

Explanation:

A computer is a device that manipulates information, or data accrding to the instructions given to it and give us an output. It has the ability to store, retrieve, and process data.

6 0
4 years ago
How to find the volume of cube in computer in QBASIC program ​
otez555 [7]

Answer:

QBasic Programming

REM PROGRAM TO DISPLAY VOLUME OF CUBE. CLS. INPUT “ENTER LENGTH”; L. ...

USING SUB PROCEDURE.

DECLARE SUB VOLUME(L) CLS. INPUT “ENTER LENGTH”; L. ...

SUB VOLUME (L) V = L ^ 3. PRINT “VOLUME OF CUBE ”; V. ...

USING FUNCTION PROCEDURE.

DECLARE FUNCTION VOLUME (L) CLS. ...

FUNCTION VOLUME (L) VOLUME = L ^ 3.

3 0
3 years ago
Provided you have an Internet connection and functional Web browser, gather information on three different commercial RAID contr
aalyn [17]

Answer:

1). Serial ATA (SATA): SATA drives are base hard drives. Serial ATA was designed to  replace the older parallel ATA (PATA) standard (often called by the old name IDE), offering several advantages  over the older interface: reduced cable size and cost (7 conductors instead of 40), native hot swapping, faster  data transfer through higher signaling rates, and more efficient transfer through a I/O queuing protocol. On  some systems without a controller, these can be cabled instead to the onboard SATA connections on the  motherboard. On smaller servers with a controller, they can still be cabled because these systems will not have  a backplane. Cabled hard drives are not hot swappable.

2). Near Line SAS: Near Line SAS are enterprise SATA drives with a SAS interface, head, media, and rotational  speed of traditional enterprise-class SATA drives with the fully capable SAS interface typical for classic SAS

drives. This provides better performance and reliability over SATA. Basically it is a hybrid between SATA and SAS.

3). Serial Attached SCSI (SAS): SAS is a communication protocol used in Enterprise hard drives and tape drives.  SAS is a point-to-point serial protocol that replaces the older based parallel SCSI bus technology (SCSI). It uses  the standard SCSI command set. These have extra connections through the top of the SATA connection. These  are the top end in performance for electromechanical drives.

4). Solid-State Drive (SSD): An SSD is a data storage device that uses integrated circuit assemblies as memory to  store data persistently. SSD technology uses electronic interfaces compatible with traditional block  input/output (I/O) hard disk drives. SSDs do not employ any moving mechanical components, which  distinguishes them from traditional magnetic disks such as hard disk drives, which are electromechanical  devices containing spinning disks and movable read/write heads. Compared with electromechanical disks, SSDs  are typically less susceptible to physical shock, are silent, and have lower access time and latency. Typically  because of these features, SSD drives can be the fastest I/O in the market today in standard hard drive form factor.

Explanation:

5 0
4 years ago
Match each logical function with its description. AND COUNTIF SUMIF IF tests for a certain condition and returns one of two valu
lakkis [162]
1. IF
2. AND
3. COUNTIF
4. SUMIF
4 0
4 years ago
Other questions:
  • When you insert an object in a document, Word always inserts it as a floating object. true or false
    14·1 answer
  • How do i change my Email in brainly ? ​
    7·2 answers
  • Why are user application configuration files saved in the user’s home directory and not under /etc with all the other system-wid
    6·1 answer
  • The duties of a database administrator include determining which people have access to what kinds of data in the database; these
    13·2 answers
  • In a penetration test, a ________ team consists of IT staff who defend against the penetration testers. They are generally aware
    14·1 answer
  • What can you use on Code.org's Web Lab to find and fix problems when you are writing code for your website?
    13·1 answer
  • Just took a test and I got 5 wrong and I wanted to know the correct answers
    10·1 answer
  • 5. Name the special window that displays data, when you insert a chart.
    8·1 answer
  • What is an example of a one-to-many relationship?
    9·2 answers
  • 2
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!