![braegan64](/avatars/27210.jpg)
braegan64
11.11.2020 •
Computers and Technology
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() function.
Solved
Show answers
More tips
- H Health and Medicine How to Treat Whooping Cough in Children?...
- H Health and Medicine Simple Ways to Lower Cholesterol in the Blood: Tips and Tricks...
- O Other How to Choose the Best Answer to Your Question on The Grand Question ?...
- L Leisure and Entertainment History of International Women s Day: When Did the Celebration of March 8th Begin?...
- S Style and Beauty Intimate Haircut: The Reasons, Popularity, and Risks...
- A Art and Culture When Will Eurovision 2011 Take Place?...
- S Style and Beauty How to Choose the Perfect Hair Straightener?...
- F Family and Home Why Having Pets at Home is Good for Your Health...
- H Health and Medicine How to perform artificial respiration?...
- H Health and Medicine 10 Tips for Avoiding Vitamin Deficiency...
Answers on questions: Computers and Technology
- C Computers and Technology I’m tutoring a kindergartener virtually and have run out of things to do that will keep her engaged. Does anybody have any ideas?...
- C Computers and Technology Anna is creating a digital portfolio, including her professional work showcasing the designs she created. What should she add to each work? O A. brief description of...
- C Computers and Technology How do I convert years to days on Python. For example, if I were to enter 3 years it should output You are 1095 days old ....
- S Spanish What s the infinitive of visto and what s the infinitive?...
- M Mathematics Easy math Show all work...
- M Mathematics Square root of n^2, if n 0...
- M Mathematics G(x)=2x−8/6x+6, evaluate g(2)...
- M Mathematics Pictured below is quadrilateral QRST. Which statement is NOT sufficient to prove that QRST is a rectangle?...
- M Mathematics Whats a example for a equivalent expression?...
- P Physics Calculate the charge flowing in 3 minutes from a cell that produces a current of 20mA...
Ответ:
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;
Note that: if user enters a non integer character such as (alphabet, etc), only the integer part will be convert.
For instance,
40a will be outputted as 40
Ответ:
The most common size for desktop hard drives is 3.5 inches, they tend to be faster and more reliable, and have more capacity. But they also make more noise.
Explanation:
If you are continually deleting and installing programs or creating content, the disc must have good reliability.
Keep in mind that larger hard drives are also a little slower, so it is preferable to opt for two smaller ones. Large hard drives are partitioned so there is no problem gettin
chbdg good performance, but if you put everything on one big disk and it breaks, you will lose everything.
If you buy 2 small disks, check that the motherboard does not limit the speed of a second hard disk.