Now, before we can execute the hello.c program, recall that we must compile it with a compiler, translating it from source code into machine code (i.e., zeroes and ones). Execute the command below to do just that:
make hello
And then execute this one again:
ls
This time, you should see not only hello.c
but hello
listed as well? You’ve now translated the source code in hello.c
into machine code in hello
.
Now execute the program itself by executing the below.
./hello
Hello, world, indeed!
Suffice it to say, no matter how you compile or execute this program, it only ever prints hello, world. Let’s personalize it a bit, just as we did in class.
Modify this program in such a way that it first prompts the user for their name and then prints hello, so-and-so, where so-and-so is their actual name.
As before, be sure to compile your program with:
make hello
And be sure to execute your program, testing it a few times with different inputs, with:
./hello
Execute the below to evaluate the correctness of your code using check50. But be sure to compile and test it yourself as well!
check50 cs50/problems/2021/x/hello
Execute the below to evaluate the style of your code using style50.
style50 hello.c
Execute the below to submit your work.
submit50 cs50/problems/2021/x/hello