Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
124 views1 page

When Green Flag Clicked Hello, World

This document compares Scratch and C programming languages and provides a basic "Hello World" example in C. It explains that printf is the equivalent of "say" in Scratch for printing output. The C example prints "hello, world" with a new line at the end using \n. It also notes that C uses double quotes and semicolons as syntax.

Uploaded by

Wildan Irfansyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views1 page

When Green Flag Clicked Hello, World

This document compares Scratch and C programming languages and provides a basic "Hello World" example in C. It explains that printf is the equivalent of "say" in Scratch for printing output. The C example prints "hello, world" with a new line at the end using \n. It also notes that C uses double quotes and semicolons as syntax.

Uploaded by

Wildan Irfansyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Week1 https://docs.cs50.net/2016/fall/notes/1/week1.

html

Scratch vs. C
hello, C
The CS50 Library
Data Types
More C

Now that weve explored some basic programming concepts with Scratch, we can try to use the same
ideas with a more traditional language, C.

Recall that last week, to run our program in Scratch, we would begin with a block that read when
greenflagclicked .

Our example of having Scratch say hello,world can be translated to the following C:

#include <stdio.h>

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

printf is the equivalent of say in Scratch, and it will print whatever is inside the parentheses.

We notice a bit of syntax, like the double quotes and the semicolon, but we can focus on one
piece at a time.

In Scratch, say was a function that took an argument, or parameter, and the equivalent line in C is:

printf("hello,world\n");

The \n prints a new line, like pressing enter after typing out that message.

And in the case of loops, in Scratch we might have a forever block that does something over and
1 of 24 12/8/2017, 7:49 PM

You might also like