185k views
2 votes
Assume that c is a char variable has been declared and already given a value. Write an expression whose value is true if and only if c is a newline character.

1 Answer

5 votes

Answer:

(c == '\\')

Step-by-step explanation:

The following code in C++ shows the use of this expression

#include <iostream>

using namespace std;

int main()

{

char c;

cout<<"Enter a character for c"<<endl;

cin>>c;

if (c == '\\'){

cout<<"True"<<endl;

}

else

cout<<"False"<<endl;

return 0;

}

User Vanvasquez
by
6.7k points