-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab2.cpp
More file actions
38 lines (35 loc) · 916 Bytes
/
Lab2.cpp
File metadata and controls
38 lines (35 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <string>
using namespace std;
int main() {
string com;
int a = 0;
cout << "Enter comment: ";
getline(cin, com);
if (com.size() >= 2 && com[0] == '/') {
if (com[1] == '/') {
cout << "It is a comment" << endl;
}
else if (com[1] == '*') {
int i = 2;
while (i < com.size() - 1) {
if (com[i] == '*' && com[i + 1] == '/') {
cout << "It is a comment" << endl;
a = 1;
break;
}
i++;
}
if (a == 0)
cout << "It is not a comment" << endl;
}
else {
cout << "It is not a comment" << endl;
}
}
else {
cout << "It is not a comment" << endl;
}
cout << "\nCompiled by : Subodh Ghimire" << endl;
return 0;
}