C vs. Ch
Back to CS16 topics
Introduction
In CS16, we are using the Ch interpreter rather than standard C.
We are using Ch because we believe it will make learning C easier.
But, because your textbook presents standard C, there are a few things that may be helpful for you to know about the differences between Ch and standard C.
Differences
Declaring Variables
- In standard C, all variables must be declared at the beginning of a block of code.
- In Ch, you can declare variables anywhere in a block of code.
- C++ and Java (languages you'll learn in CS24 and CS56) behave the same way as Ch in this regard.
#includes
- In standard C, you must use #include <stdio.h> at the top of a program that uses printf and scanf for input and output
- In standard C, you must use #include <math.h> at the top of a program that uses the sqrt function
- In Ch, you can leave off these #includes, and the program will still work correctly.
program structure
- In standard C, you must format your program as a "main function", typically starting with, for example,
int main(void)
and ending with return 0;
- In Ch, this is not necessary. Your program can simply be a list of statements.