You can use the function get line to read a string containin
Solution
a ) The getline() function is used as the input function which is unformatted . It extracts the characters until it reaches the delimiting character \'\ \' or the number of characters specified by the user to input . It requires the header file <string> in program .
The syntax of the function getline is given by ,
The getline function can also read string having blanks , hence the answer is true for the question .
Find the example program below to input a string with blanks and print it .
#include <iostream>
int main () {
char name[100] ;
std::cout << \"Enter name: \";
std::cin.getline (name,100);
std::cout << \"Name is \" <<name ;
return 0;
}
Output :
b ) The straeam object used in c++ to access the input is cin . It is a formatted input operation , It uses the extraction operator to perfom its function . The cin object can access any type of data like integer type , charcater type , string etc. The accessed data is stored into an varaible decaled in the program . it requires the library header file #include <iostream.h> in program because it is a standard input function.
If a user inputs incorrect type of data then the access operation gets fail which causes error in program .
The Syntax of the formatted input is given as :
cin >> Variable_name ;
The statement must end with a semicolon .
In the given question the correct option is d , cin >> x >> y ;
It accesses two values for the variables x and y .
