I'd like to ask you a very basic question
I was not used to using the cout command, so I was curious about it after trying many things.
If you look at the code below, for convenience of explanation, we put the constant in "" for cases 1 to 6 and marked only the constant for cases 7 to 12.
When I tried the output in two comparative ways, both worked fine.
The question I want to ask here is whether it is okay to use without quotation marks when outputting constants from cout!
using namespace::std;
int main() { int mon;
cin >> mon;
switch (mon){
case 1 : cout << "31"; break;
case 2 : cout << "28"; break;
case 3 : cout << "31"; break;
case 4 : cout << "30"; break;
case 5 : cout << "31"; break;
case 6 : cout << "30"; break;
case 7 : cout << 31; break;
case 8 : cout << 31; break;
case 9 : cout << 30; break;
case 10 : cout << 31; break;
case 11 : cout << 30; break;
case 12 : cout << 31; break;
}
return 0;
}
c++ cout
cout<<"31";
is the output of the string "31"
as cout.
cout<<31;
is the output of the integer 31
as cout.
To compare in C language, the above is printf("%s", 31");
; the below is printf("%d", 31);
© 2024 OneMinuteCode. All rights reserved.