M1D12: CS50 C

source code – code that you the human programmer write.

Computers understand information represented by binary or machine code.

There will be letters, numbers, and instructions.

Compiler

compiler – convert source code in machine code.

A compiler is a special program that translates a programming language’s source code into machine code, bytecode or another programming language.

Writing Good Code

  • correctness
  • design
  • style

#include <stdio.h>

int main(void)
{
    printf("hello, world\n");
}

Syntax highlighting – a feature of typical text editors that analyzes the code that you’ve typed.

; is added on some lines, but not all, normally after a statement.

\n escape character

#include <stdio.h>

int main(void)

/* This is like the Green Flag being clicked on Scratch */

stdio – Standard I/O Library (Input/Output)

https://manual.cs50.io/

https://manual.cs50.io/#cs50.h

get_char – get a single character from the user’s keyboard

get_int – get an integer from the user’s keyboard

get_string – get a sequence of text from the user’s keyboard, and a bunch

arguments → function → return value

what's your name → ask and wait → answer

return value – anything you want in variables. a value you get back from a function that you can use or reuse.

string answer = get_string("What's your name? ");

= is an assignment

Leave a Reply