QUESTION 6 What is the difference between \"cin\" and \"getline\" ? in one sente
ID: 3673159 • Letter: Q
Question
QUESTION 6
What is the difference between "cin" and "getline" ? in one sentence.
Path: p
Words:0
10 points
QUESTION 7
What should be changed in this code so that it performs the intended function ?
#include<iostream>
#include<string>
using namespace std;
char q;int main()
{
int name;
cout << "Enter your first and last names ";
getline(cin, name);
cout << " Your name is: " << name;'
cout << " Enter a letter to exit." << endl;
cin >> q;
return 0;
}
Change char q; to string q;
Change int name; to string name;
Change getline(cin, name); to cin >> name;
Change int name; to char name;
10 points
QUESTION 8
The following code will compile:
#include<iostream>
#include<string>
using namespace std;
char q;int main()
{
int zip1, zip2, zip3, zip4;
cout << "Enter four different zip-codes ";
cin >> zip1 >> zip2;cin >> zip3 >> zip4;
cout << " Enter a letter to exit." << endl;cin >> q;
return 0;
}
True
False
10 points
QUESTION 9
What is wrong in the following code?
#include<iostream>
#include<string>
using namespace std;
char q;
int main()
{
int zip1, zip2, zip3, zip4;
cout << "Enter three different zip-codes ";
cin >> zip1 >> zip2 >> zip3 >> zip4;
cout << " Enter a letter to exit." << endl;
cin >> q;
return 0;
}
This code will not compile.
The compiler expect four entry while the user will enter three different numbers.
The compiler expect three entries while the user want to enter four values.
Nothing is wrong with this code.
10 points
QUESTION 10
Write a code that:
ask the user to enter a variable, then save the user entry as x of type double.
set y = ( ( -x - sqrt(x^2 - 8*x) )/ (2 - x);
if denominator is zero then display "undefined"
else
display the value for y
Compile your code.
Test your programme with x = -1
-- Font family --Andale MonoArialArial BlackBook AntiquaComic Sans MSCourier NewGeorgiaHelveticaImpactSymbolTahomaTerminalTimes New RomanTrebuchet MSVerdanaWebdingsWingdings -- Font size --1 (8pt)2 (10pt)3 (12pt)4 (14pt)5 (18pt)6 (24pt)7 (36pt) -- Format --HeadingSub Heading 1Sub Heading 2ParagraphFormatted Code -- Font family -- -- Font size --Path: p
Words:0
Explanation / Answer
QUESTION-6) Difference between "cin" and "getline"
The difference that i see it that, in getline you will get the spaces all in input, but in cin spaces are not allowed.
QUESTION-7)
b. Change int name; to string name;
Because you cant store string in int type datatype
QUESTION-8)
The following code will compile
QUESTION-9)
d. Nothing is wrong with this code.
It will compile perfectully
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.