What is the output of this C++ program? #include <iostream> using namespace std; int main( ) { char line[100]; cin.getline( line, 100, 't' ); cout << line; return 0; } t 100 None of the mentioned It will print what we enter till character t is encountered in the input data
Question
What is the output of this C++ program?
#include <iostream>
using namespace std;
int main( )
{
char line[100];
cin.getline( line, 100, 't' );
cout << line;
return 0;
}
t
100
None of the mentioned
It will print what we enter till character t is encountered in the input data
Solution
The output of this C++ program will be whatever you input until the character 't' is encountered. This is because the cin.getline() function reads characters from an input stream and stores them as a c-string into the char array. The function stops reading input after it has stored n-1 characters or when it encounters the delimiter character (in this case, 't'). So, the correct answer is "It will print what we enter till character t is encountered in the input data".
Similar Questions
What will be the output of the following C code?
What will be the output of the following program?
What will be the output of the C program? ans.09119011 Previous Marked for Review Next
What would be the output of the following program?#include <stdio.h>int main( ){int j=1;while (j <= 255){printf ( "%c %d\n ", j, j );j++;}return 0;}ans.
What will be the output of the following program?Note: This question helps in clearing AMCAT exam.12345678910#include <stdio.h>int main() { int c = 0, e = 0; for (e = 0;e < 5; e++) { c++; if (e == 3) break; } printf("%d",c);}
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.