cout<<"Hello, world!" <<endl;

Picture by  Pixabay Pixabay

Hey everyone!, the new tasks of class where:

  1. The Hello world program (to check everything was ok and that we had all our tools correctly installed).
  2. The WSQ 01.

 

Basically what I did was reading our book (chapter 1 and 2) and then I was ready to start; I use Atom so I opened it and did the coding, the only problem I had was that I needed to add the «using namespace std;» library and then I saved, compiled and ran the program once again  and I had no errors. I had to ask ken how to compile and run and for those who don’t know just as I did here are the steps:

  1. Save the program (you have to remember where you saved it so I recommend saving it on your desktop ‘cause you’ll have to find it on terminal and thats how I did it)
    Note: you have to make sure it saves as .cpp
  2. Open your terminal
  3. Write: cd Desktop/ (or wherever your file its located)
  4. Then type g++ and the name of your file. Example: g++ Hellow.cpp
  5. Then an executable will be created, mine was called a.out, so then I typed ./a.out
  6. voilà! 🙌🏼

Here’s my code, just click where it says «Hellow.cpp».

Captura de pantalla 2017-01-18 a la(s) 21.42.45.png

WSQ01: «easy AF» 😅

For doing this you’ll basically need the same things you needed to do the «Hello world» program, if you want to get ahead and read chapter 3 of the book it may help you to get familiar with working with numbers, although I think it’s not that important for now.

Few things that should help in order to do this assignment correctly:

  1. First things to do in your main: declare the variables (the ones you need to do the calculations, you’ll be fine with 2 variables).
  2. The writing process will be the same, the only new thing is that you’ll need to use cin>> when you want to save the value given by the user in one of your variable, it’ll should be something like this:cout<<«Please give me the first number»<<endl;
    cin>>no1;The other thing is that you should write the operation you want to do before the end line, something like this:

    cout<<«Sum:»<<no1+no2<<endl;

Captura de pantalla 2017-01-18 a la(s) 21.43.36.png

It’s just a matter of structure and getting used to it. You should try it.

As always my program at GitHub here, the file is WSQ01.cpp
The void newLine thing is just esthetic, it’s to give a line between the text where you put it.

PD: I am a Mac user so this blog may be more useful to Mac users as well.

 

L.out 

4 comentarios en “cout<<"Hello, world!" <<endl;

Deja un comentario