/*
This is a C-like comment.
The program determines whether
an integer is odd or even.
*/
#include < iostream >
using namespace std;
int main( ) {
int num; // This is a C++ single-line comment.
// read the number
cout << "Enter number to be tested: ";
cin >> num;
// see if even or odd
if ((num%2)==0) cout << "Number is even\n";
else cout << "Number is odd\n";
return 0;
}
Multiline comments cannot be nested but a single-line comment can be nested within a multiline comment.
/* This is a multiline comment
Inside which // is nested a single-line comment.
Here is the end of the multiline comment.
*/
No comments:
Post a Comment