What will be the output of the following C++ code? [code] #include <iostream> #include <string> using namespace std; int main(int argc,

Trương Duy

New member
What will be the output of the following C++ code?
Code:
#include <iostream> 
#include <string>
using namespace std; 
int main(int argc, char const *argv[])
{
	string str;
	cin>>str;
	cout<<str;
	return 0;
}
A. str
B. Input provided by the user
C. Error
D. Segmentation fault
 
Answer: b
Explanation: There is no error in the program and as we are asking the user to enter a string and printing that string to console. Therefore output will be the string provided by the user.
 

Tìm kiếm

Back
Top