0

explain for syntax used by clion for c++

e.g: for hello: #include <iostream> int main(){ std:: cout <<"hello"<<std::endl; return 0; } l am confused with ds syntax diff from what l learnt

11th Apr 2018, 8:57 AM
Elijah Kwahla
Elijah Kwahla - avatar
6 Answers
0
On the top is #include - include libraries. The most important thing is function called main() of type int. It's 'commands' is closed in brackets {}. There is program starts. If everything worked fine then it return 0.
11th Apr 2018, 9:01 AM
Bartosz Pieszko
Bartosz Pieszko - avatar
0
ok bt if common syntax to print hello it gives error...This is where my problem is
11th Apr 2018, 9:05 AM
Elijah Kwahla
Elijah Kwahla - avatar
0
In c++ there are 2 top ideas to print something. The first one std: :cout and it looks like you wrote. The second one is printf and it looks like: printf("I'm writing %d\n", int(5)); You have to know %- in the second idea. Different % for different type of variable.
11th Apr 2018, 9:11 AM
Bartosz Pieszko
Bartosz Pieszko - avatar
0
ok thank you
11th Apr 2018, 9:14 AM
Elijah Kwahla
Elijah Kwahla - avatar
0
Maybe you should do #include <iostream> using namespace std; int main(){ cout <<"hello"<<endl; return 0; }
11th Apr 2018, 9:22 AM
E_E Mopho
E_E Mopho - avatar
0
using namespace std when there are just 2 times you call something from namespace std? No need for using namespace std here.
11th Apr 2018, 1:20 PM
Alex
Alex - avatar